Graal Forums

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

nyghtGT 10-02-2001 04:52 PM

tokens
 
ok to check a word numbers numerical value you use 'strtofloat'
so:
NPC Code:

if (strtofloat(#t(1))>=1) {hide;
}


So would setting the token to a variable work in the command like for if i say "warpto 30 30 onlinestartlocal.graal":
NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Level Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (strtofloat(#t(1))>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}
if (this.warpcommand=0) {
setstring newlevel,#t(3);
this.newx=#t(1);
this.newx=#t(2);
setlevel2 #s(newlevel),#v(this.newx),#v(this.newy);
}


Bravo_Admin1 10-02-2001 04:55 PM

Re: tokens
 
Quote:

Originally posted by nyghtGT
ok to check a word numbers numerical value you use 'strtofloat'
so:
NPC Code:

if (strtofloat(#t(1))>=1) {hide;
}


So would setting the token to a variable work in the command like for if i say "warpto 30 30 onlinestartlocal.graal":
NPC Code:

// NPC made by Nyght v3.5
if (playerenters) {
toweapons *Level Warper
}
while (created && !staff) {
destroy;
}
if (playerchats && staff && startswith(warpto,#c)) {
tokenize #c;
if (strtofloat(#t(1))>=0) {
this.warpcommand=0;
}else setlevel #t(1);
}
if (this.warpcommand=0) {
setstring newlevel,#t(3);
this.newx=#t(1);
this.newx=#t(2);
setlevel2 #s(newlevel),#v(this.newx),#v(this.newy);
}


:confused:

nyghtGT 10-02-2001 04:58 PM

nevermind
 
nevermind i just set strings for the new x and y and that should work ... thanx anyway

Bravo_Admin1 10-02-2001 04:59 PM

Re: nevermind
 
Quote:

Originally posted by nyghtGT
nevermind i just set strings for the new x and y and that should work ... thanx anyway
:spam:

nyghtGT 10-02-2001 05:03 PM

why wont this work ?
 
why wont this work ???:
setlevel2 #s(newlevel),#s(newx),#s(newy);

Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)

btedji 10-02-2001 07:17 PM

Re: why wont this work ?
 
Quote:

Originally posted by nyghtGT
why wont this work ???:
setlevel2 #s(newlevel),#s(newx),#s(newy);

Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)

it should be:
setlevel2 #s(newlevel),strtofloat(#s(newx)),strtofloat(#s(ne wy));

nyghtGT 10-03-2001 02:41 AM

but ...
 
but when i use them directly like this:
NPC Code:

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


I get another error .... Try it yourself you'll see

nyghtGT 10-03-2001 02:47 AM

Re: Re: why wont this work ?
 
Quote:

Originally posted by btedji


it should be:
setlevel2 #s(newlevel),strtofloat(#s(newx)),strtofloat(#s(ne wy));

would strtofloat use working with tokens ???
'strtofloat(#t(1))'

btedji 10-03-2001 02:50 AM

strtofloat() should work with any strings

nyghtGT 10-03-2001 03:13 AM

yeah !!!
 
Quote:

Originally posted by btedji
strtofloat() should work with any strings
GRACIAS !!!!! :D :D :D :D

Aknts 10-03-2001 03:18 AM

Here I was bored. So I scripted it.
// NPC made by Spanky
if (playertouchsme) {
toweapons *Level Warper;
}
if (playerchats&&isweapon) {
tokenize #c;
if(strequals(#t(0),warpto)){
if(tokenscount==4){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #t(3),this.x,this.y;
}
if(tokenscount==3){
this.x=strtofloat(#t(1));
this.y=strtofloat(#t(2));
setlevel2 #L,this.x,this.y;
}
}}

btedji 10-03-2001 03:21 AM

this is a shorter way of doing it

NPC Code:

if(startswith(warpto ,#c))
{tokenize #c;

if(tokenscount==4)
{setlevel2 #t(1),strtofloat(#t(2)),strtofloat(#t(3));}
}


Aknts 10-03-2001 03:23 AM

No with mine you can say either
Warpto #L,x,y;
or
Warpto x,y;

btedji 10-03-2001 03:31 AM

Quote:

Originally posted by Aknts
No with mine you can say either
Warpto #L,x,y;
or
Warpto x,y;

on mine if you wanted to warpto somewhere on the same level just type the level name in!!

PresShinP2P 10-03-2001 03:33 AM

you could shorten it, example:
// NPC made by Spanky
if (playertouchsme) {
toweapons *Level Warper;
}
if (playerchats&&isweapon) {
tokenize #c;
if(strequals(#t(0),warpto)){
if(tokenscount==4){
setlevel2 #t(3),strtofloat(#t(1)),strtofloat(#t(2));
}
if(tokenscount==3){
playerx=strtofloat(#t(1));
playery=strtofloat(#t(2));
}
}}

shortened, but you sacrifice readablility


All times are GMT +2. The time now is 04:40 PM.

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