Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   tokenizing >,=,< (https://forums.graalonline.com/forums/showthread.php?t=13071)

nyghtGT 09-27-2001 07:39 AM

tokenizing >,=,<
 
ok i got the standard tokenizing down but like if the token saved is a number is there a way i can use it as in the below ?

NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Staff Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (#t(1)>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}



I dont think '(#t(1)>=0)' is right but i want if the number value of the token is greater than or equals to zero to set the variable this.warpcommand to 0 ....

please help ....

Merlin 09-27-2001 08:43 AM

if (playerchats) {
tokenize #c;
if (startswith(warpto,#c)) {
if (staff) {
if (tokenscount==3) {
setstring local.x,#t(1);
setstring local.y,#t(2);
setstring local.level,#t(3);
timeout = .5;
}
}
}
}

if (timeout) {
setlevel2 #s(local.level),#s(local.x),#s(local.y);
}

[edit] oh i see...
hmm well...
you can do

this.counter = strtofloat(#t(1));

if (this.counter => 0) {
action;
}

nyghtGT 09-27-2001 09:12 AM

Quote:

Originally posted by Merlin
if (playerchats) {
tokenize #c;
if (startswith(warpto,#c)) {
if (staff) {
if (tokenscount==3) {
setstring local.x,#t(1);
setstring local.y,#t(2);
setstring local.level,#t(3);
timeout = .5;
}
}
}
}

if (timeout) {
setlevel2 #s(local.level),#s(local.x),#s(local.y);
}

[edit] oh i see...
hmm well...
you can do

this.counter = strtofloat(#t(1));

if (this.counter => 0) {
action;
}

ok i understand what your doing .... but here is what i want ...

i want it so if the playerchats and it starts with 'warpto' it tokenizes #c. ( I can do that but) I wanna know if there is a special command to check the numerical value of a token?(the token being >,=,<)

BocoC 09-27-2001 09:15 AM

All tokens are saved as strings, so use the command 'strtofloat()' to convert it into a numerical value. You can than use >, =, or < to check the number.

tokenize #c;
if (strtofloat(#t(1))>0)) { }

nyghtGT 09-27-2001 09:19 AM

Quote:

Originally posted by BocoC
All tokens are saved as strings, so use the command 'strtofloat()' to convert it into a numerical value. You can than use >, =, or < to check the number.

tokenize #c;
if (strtofloat(#t(1))>0)) { }

Thats exactly what i wanted to hear Boco thanx !!!


All times are GMT +2. The time now is 11:13 PM.

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