Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Flag problems? (https://forums.graalonline.com/forums/showthread.php?t=55866)

falco10291029 10-31-2004 04:51 AM

Flag problems?
 
Ok, here's my problem, there is osbviously something wrong with how i set up the flag in the following script, but i cant figure out what (I know it's the flag because i ran several tests to check for the problem). It only does this once, even if the player has a lot of the string, acting like i have it set as if, instead of while. changing it to a for loop didnt help either.
NPC Code:


while (strtofloat(#s(clientr.#t(1)))>=1) {
freezeplayer .75;
setcharani ek_mine,;
setstring clientr.#t(1)dust,#v(strtofloat(#s(clientr.#t(1)du st))+1);
setstring clientr.#t(1),#v(strtofloat(#s(clientr.#t(1)))-1);
message #s(clientr.#t(1));
sleep .75;
setcharani idle,;
}



I have tried figuring it out myself, and i only put in part of the script, so i dont expect this thread to be closed/deleted before i solve this prob.

Slash-P2P 10-31-2004 05:40 AM

Quote:

Originally Posted by falco10291029
Ok, here's my problem, there is osbviously something wrong with how i set up the flag in the following script, but i cant figure out what (I know it's the flag because i ran several tests to check for the problem). It only does this once, even if the player has a lot of the string, acting like i have it set as if, instead of while. changing it to a for loop didnt help either.
NPC Code:

some code


I have tried figuring it out myself, and i only put in part of the script, so i dont expect this thread to be closed/deleted before i solve this prob.

I suggest a timeout instead of while
is there anything using tokenize so #t(1) works?

falco10291029 10-31-2004 05:44 AM

Quote:

Originally Posted by SlashP2P
I suggest a timeout instead of while
is there anything using tokenize so #t(1) works?

A timeout will not work in the script i have (i dont feel like posting the whole thing, just trust me), and yes, i am not stupid, it does tokenize it beforehand.

Slash-P2P 10-31-2004 05:49 AM

Quote:

Originally Posted by falco10291029
A timeout will not work in the script i have (i dont feel like posting the whole thing, just trust me), and yes, i am not stupid, it does tokenize it beforehand.

Try putting the tokenize in the while loop and keep it wherever it is now too.

VeX_RaT_Boy 10-31-2004 07:02 PM

1. That's not a flag, it's a string.

2. clientr. strings can only be set SERVERSIDE.

3. I do not think a 'while' loop is the best thing to do here. But don't kill me if I'm wrong, but from what I see, other things might be better.

Slash-P2P 10-31-2004 07:07 PM

Quote:

Originally Posted by VeX_RaT_Boy
2. clientr. strings can only be set SERVERSIDE.

I looked at the whole script and it is serverside.

VeX_RaT_Boy 10-31-2004 07:11 PM

Is a player active in the serverside script?

Slash-P2P 10-31-2004 08:05 PM

Quote:

Originally Posted by VeX_RaT_Boy
Is a player active in the serverside script?

Its under if (playerchats)

falco10291029 10-31-2004 09:04 PM

Yeah i tried a timeout loop but it doesnt even set the timeout if it;s serverside for some reason which is crap.

Slash-P2P 10-31-2004 10:50 PM

Quote:

Originally Posted by falco10291029
Yeah i tried a timeout loop but it doesnt even set the timeout if it;s serverside for some reason which is crap.

I don't know what timeout you used, but you cant have anything less than .1 for a serverside timeout.

Dach 10-31-2004 11:09 PM

Quote:

Originally Posted by falco10291029
I have tried figuring it out myself, and i only put in part of the script, so i dont expect this thread to be closed/deleted before i solve this prob.

It's against the rules to post full code to solve someone's problem, not just post full code...

Quote:

A timeout will not work in the script i have
I'm sure it would, regardless of how much you'd need to change.


try taking out all of that unnecessary code first then find the problem.
PHP Code:

while (strtofloat(#s(clientr.#t(1)))>=1) {
  
setstring clientr.#t(1),#v(strtofloat(#s(clientr.#t(1)))-1); 
  
message clientr.#t(1) = #s(clientr.#t(1));
  
sleep .75;


PHP Code:

if (playerchats) {
  
tokenize #c;
  
setstring test#t(0),5;
  
timeout .1;
}
if (
timeout) {
  if (
strtofloat(#s(test#t(0)))>=1) {
    
setstring test#t(0),#v(strtofloat(test#t(0))-1);
    
message test#t(0) = #s(test#t(0));
  
}
  
timeout .1;



falco10291029 11-01-2004 12:01 AM

I just tried using a timeout, it works fine offline meaning it's an online problem.. here's the new code:

PHP Code:

if (playerchats&&startswith(crush,#c)) {
  
tokenize #c;
  
if (strtofloat(#s(clientr.#t(1)))>0) {
    
playerx=x;
    
playery=y+5;
    
playerdir=0;
    
timeout=1;
  } else {
    
insertstring client.messages,0,You don't have any #t(1) gems.;
  }
}
if (timeout) {
  setcharani idle,;
  freezeplayer 1;
  setcharani ek_mine,;
  setstring clientr.#t(1)dust,#v(strtofloat(#s(clientr.#t(1)dust))+1);
  setstring clientr.#t(1),#v(strtofloat(#s(clientr.#t(1)))-1);
  setplayerprop #c,#s(clientr.#t(1));
  if (strtofloat(#s(clientr.#t(1)))<=0) {
    setcharani idle,;
    message Your crushing is completed;
  }
  else  {
    timeout=1;
  }



Andares 11-01-2004 04:29 AM

Quote:

Originally Posted by Slash-P2P
I suggest a timeout instead of while
is there anything using tokenize so #t(1) works?

I wasn't even aware the while command existed on gscript. :rolleyes:
I use timeouts. Timeouts own all.

xAndrewx 11-01-2004 11:52 AM

Quote:

Originally Posted by Andares
I wasn't even aware the while command existed on gscript. :rolleyes:
I use timeouts. Timeouts own all.

I never new about insertstring :o

VeX_RaT_Boy 11-02-2004 01:16 AM

Quote:

Originally Posted by falco10291029
I just tried using a timeout, it works fine offline meaning it's an online problem.. here's the new code:

PHP Code:

//MY SCRIPT 


Is this a weapon, or what?


All times are GMT +2. The time now is 03:51 AM.

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