![]() |
tokens
ok to check a word numbers numerical value you use 'strtofloat'
so: NPC Code: So would setting the token to a variable work in the command like for if i say "warpto 30 30 onlinestartlocal.graal": NPC Code: |
Re: tokens
Quote:
|
nevermind
nevermind i just set strings for the new x and y and that should work ... thanx anyway
|
Re: nevermind
Quote:
|
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) |
Re: why wont this work ?
Quote:
setlevel2 #s(newlevel),strtofloat(#s(newx)),strtofloat(#s(ne wy)); |
but ...
but when i use them directly like this:
NPC Code: I get another error .... Try it yourself you'll see |
Re: Re: why wont this work ?
Quote:
'strtofloat(#t(1))' |
strtofloat() should work with any strings
|
yeah !!!
Quote:
|
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; } }} |
this is a shorter way of doing it
NPC Code: |
No with mine you can say either
Warpto #L,x,y; or Warpto x,y; |
Quote:
|
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.