![]() |
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 |
Quote:
|
Quote:
|
Quote:
mine dont work right ofline though so if you use my old one use setlevel then set the players x and y to a new location .... |
Quote:
NPC Code: |
Quote:
|
bryan, youre code wouldnt work if they wanted to just change x&y
kamietsu, i dont like else if :( |
Quote:
|
i do what i please
|
i know this but GScript really isnt my perferd language anyway :)
so i dont spend much time learning it but it would help if some one could tell me how to use save[] and {server.vars} and online stuff like that, cuz i have never used the online script editor |
Quote:
|
i know this kamietsu but i dont know wether to go:
if (blah-blah){ }else if(blah-blah){ } or: if (blah-blah){ }elseif(blah-blah){ } or: if (blah-blah){ else if(blah-blah){ } or: if (blah-blah){ elseif(blah-blah){ } i dunno what is the best to do so i just use if :confused: |
Quote:
|
| All times are GMT +2. The time now is 01:37 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.