![]() |
Problems Detecting Number String?
I've tried this.
NPC Code: and NPC Code: but neither work. How do I get it so it'll read it as a number? Since like that it doesn't seem to be doing it. |
Hm, try echo()ing the value to check that it is what you think.
|
If its a string, makevar(client.cxammo)? I dunno, never had to use that one..
|
Are you sure your server's GS2 enabled?
|
float(string) will make it a number.
|
Quote:
|
The second one shouldn't work, but the first one definitely should. You should follow Skyld's advice and echo out the contents of that variable. (Also see my reply to Tyrial for explanation of the 'strings' and 'numbers' misconception)
Quote:
PHP Code:
|
Well, stuff that is good to know in gs2:
strings values of "true" and "false" can be interpreted as booleans var set to boolean value false will not exist. var with value of 0 makes the var not exist. float with value of 0 will show blank. string with value of "0", however, makes the var still exist. a string value that stores a number, in GS2, is automatically converted to a float value when performing math operations on it. a sleep-iteration loop will not store temp.vars through multiple iterations |
Alright, thanks for your help.
|
Quote:
NPC Code:function onWeaponfired() Worked - so it's obviously GS2 enabled. Also another small problem that doesn't appear to be working properly for reasons unknown NPC Code:function onKeypressed(character) And yes I have a "function putaway()" occuring later in the script. Quote:
|
Uh ok it works now, heh heh. I found the problem. There was an error in the script before hand where it had
NPC Code: instead of NPC Code: Heh. |
Well, in Skyld's mad frenzy of deleting and editing posts he deleted some actual information I had in my post. I am too lazy to retype it now, so for the "(Also see my reply to Tyrial for explanation of the 'strings' and 'numbers' misconception)" I guess you'll have to use google.
Skyld is turning into Moonie, by the looks of it. |
Quote:
NPC Code:function onKeyPressed(Code, Key) It's code, and then key :] Skyld is only doing what is right, I guess most of the posts were pointless. |
Things that you can store as boolean values rather than strings or integers makes things run faster (ex. use client.cx = true instead of client.cx = "on"). Using bitwise operators also makes things work faster, etc. (ex. (x|y) in range) rather than x in range && y in range.
When you can, use addition instead of multiplication ex. do for (i=0; i<size; i+=10) showimg(201,image,x,y); for (i=0; i<size; i++) showimg(201,image,x*10,y*10); also, when possible work in powers of two. |
Quote:
Quote:
|
ApothiX, he's trying to be helpful. True it's not related to the topic - but if you havn't realized, the problem has been solved. No problem trying to help. :P
|
Quote:
I didn't touch on everything however. One way to test that a string is being converted to a float temp.string = "10"; temp.string.type(); //should return the num value signifying string temp.string += 2; temp.string.type(); //should return the num value signifying float (Look at Script Functions : Client : TGraalVar for the num values) Of course, when passing by value in a function, Graal already knows the datatypes that go in a function unless they're user-defined, in which case they are interpreted the same as the rest of the scripting language within the function. |
| All times are GMT +2. The time now is 12:52 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.