Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Weapon won't deactivate :( (https://forums.graalonline.com/forums/showthread.php?t=27679)

G_yoshi 04-18-2002 01:54 PM

Weapon won't deactivate :(
 
For some inane reason, I cannot get my script to disable when I fire the weapon again...
NPC Code:
if (weaponfired && !timeout) {
freezeplayer .05;
//triggeraction playerx+1.5+vecx(playerdir)*2,playery+1.75+vecy(pl ayerdir)*2,chat,;
set client.chat;
timeout = 0.05;
} else if (weaponfired && timeout) {
for (this.i=0; this.i<10000; this.i++) {
hideimg this.i-1;
}
unset client.chat;
}



I've also tried using the flag I have it set, but nothing seems to work :/

I've probably done something wrong, but I can't understand what it coud be

Slaktmaster 04-18-2002 02:12 PM

I wouldn't use use weaponfired in a timeout.
I would help you with the script but I have to get to school.

G_yoshi 04-18-2002 07:19 PM

Re: Re: Weapon won't deactivate :(
 
Quote:

Originally posted by Kaimetsu
Ew, man, that's horrible. Scripts don't run all at once with all the relevant flags for that frame. Every frame, they run once for every event. That means you will never get weaponfired and timeout at the same time. Also, what the heck are you doing by setting/unsetting a flag every 0.05 seconds? Do you have any idea of the extra lag that causes?
I suppose you didn't read it very well, there's more to the script, I'm just not going to show it...instead of it being if (weaponfired && !timeout) {...} I was trying ...&& !client.chat) {...} I've done it before in a few other NPCs so I do not understand what is wrong :/

Spanko 04-18-2002 08:52 PM

It'd probably be more effective if you did:
NPC Code:
if (weaponfired) {
if (client.chat) {
for (this.i=0; this.i<10000; this.i++) {
hideimg this.i-1;
}
unset client.chat;
}
else {
freezeplayer .05;
set client.chat;
timeout=0.05;
}
}


Saga2001 04-18-2002 11:30 PM

Quote:

Originally posted by Spanko
It'd probably be more effective if you did:
NPC Code:
if (weaponfired) {
if (client.chat) {
for (this.i=0; this.i<10000; this.i++) {
hideimg this.i-1;
}
unset client.chat;
}
else {
freezeplayer .05;
set client.chat;
timeout=0.05;
}
}


Yay! I was gonna do exactly that you saved me a few minutes! :megaeek:

G_yoshi 04-19-2002 07:59 AM

Quote:

Originally posted by Spanko
It'd probably be more effective if you did:
NPC Code:
if (weaponfired) {
if (client.chat) {
for (this.i=0; this.i<10000; this.i++) {
hideimg this.i-1;
}
unset client.chat;
}
else {
freezeplayer .05;
set client.chat;
timeout=0.05;
}
}


Thanks, but it still doesn't work :/

Here's the entire script so far:
NPC Code:
// NPC made by GregoryYoshi
if (playerenters) {
setshape 1,32,32;
}

if (playertouchsme) {
toweapons InterChat;
}

if (weaponfired) {
if (client.chat) {
for (this.i=0; this.i<10000; this.i++) {
hideimg this.i-1;
}
unset client.chat;
} else {
showimg 500,dk_window.png,(screenwidth/4)-76,(screenheight/2)-120;
changeimgvis 500,4;
wraptext2 imgwidth(dk_window.png)-4,.75,,Waiting for response from other player...;
for (this.i=0; this.i<tokenscount; this.i++) {
showimg this.i,@#t(this.i),(screenwidth/4)-64,(screenheight/2)+(this.i*18)-112;
changeimgzoom this.i,.75;
changeimgvis this.i,5;
sleep .25;
}
freezeplayer .05;
set client.chat;
timeout=0.05;
}
}

if (timeout) {
freezeplayer .05;
timeout = 0.05;
}

/*
wraptext2 imgwidth(dk_window.png)-4,.75,,@#a:#K(160)#c;
for (i=0; i<10000; i++) {
hideimg i-1;
}
*/



This is an NPC I'll be adding to my PW (when it's done) that changes the way players chat on a 1on1 basis...I may just wind up putting in a keydown check routine so that players can exit the chat easily. I'll also have a special chatroom and since I hide the minimap, I may have a small window that displays toalls :)

G_yoshi 04-19-2002 08:27 AM

Quote:

Originally posted by Kaimetsu
I should just stamp a full copy of the guidelines onto everybody's foreheads.
Sorry, I've done similar NPCs and never had this problem :/

G_yoshi 04-19-2002 08:34 AM

Quote:

Originally posted by Kaimetsu


I wouldn't mind if you just posted the part that wasn't working, or at least told us the exact problem :-/

I have already posted it :/

Once I fire the weapon, I can't use 'D' again to turn it off.

G_yoshi 04-19-2002 08:48 AM

Quote:

Originally posted by Kaimetsu


Wait, this is obvious. You can't fire weapons when frozen.

>.<

I suppose I could then use disabledefmovement instead or, like I said, add in a keydown check :/

screen_name 04-19-2002 10:23 AM

man i miss this place

o well, maybe i shall return in a few months or so, lets just watch

Saga2001 04-19-2002 03:01 PM

Quote:

Originally posted by screen_name
man i miss this place

o well, maybe i shall return in a few months or so, lets just watch

lol. we all miss ya man. ;)

Quote:

Kaimetsu
I should just stamp a full copy of the guidelines onto everybody's foreheads.
*points out guidelines on forehead*

Saga2001 04-22-2002 03:11 AM

-FooL-

You could do this:

if (weaponfired || timeout && keydown(6))

Or whatever D button is... of course then you'd hafta do a check to make sure it didn't just cancel itself because of the timeout. *shrug*

emortylone 04-25-2002 09:21 PM

then put it w/ a second variable. if (this.use==2) so that way have this.use==1 be the action. and like if (this.use==1&&keydown(4)) this.use=2.
---Shifter


All times are GMT +2. The time now is 05:26 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.