Page 1 of 1
int ?
Posted: Tue Sep 13, 2005 7:57 pm
by ViPER
if(int(getcvar "this") != 1) or if(int(getcvar "that") != "1")
or
if(int(getcvar this1) != "1") or if(int(getcvar this1) != 1)
or same with if(getcvar this1 != "1")
what do the quotes do/mean and how should they be used?
Posted: Tue Sep 13, 2005 8:15 pm
by Rookie One.pl
Quotes mean that this is a value of type string. The getcvar command always returns a string. I always convert integer cvars to integer variables:
local.intvar = int(getcvar("integercvar"))
Posted: Wed Sep 14, 2005 9:04 am
by bdbodger
When you use int you convert or read the cvar as a number so the quotes should not be used like rookie said , the same goes when you use float .
Posted: Wed Sep 14, 2005 10:35 am
by ViPER
ok, i get the int. but what is float? cus i get float error when im fooling with these quotes.
Posted: Wed Sep 14, 2005 11:10 am
by bdbodger
an integer is a whole number like 1 or 2 a float is decimal like 1.5 or 3.9 you may have seen it when creating random numbers as well
local.num = randomint(26) 0 to 25
local.num = randomfloat(26) 0 to 25.9999 ? not sure now many decimal places it uses may only be 2 or could be 10 I don't know
The point is don't use quotes with numbers as was said if you don't use int(getvar whatever) then you will get a string you can use quotes in that case
if( (getcvar whatever) == "1") // ok
if ( int( getcvar whatever) == "1") // wrong
if ( int( getcvar whatever) == 1) //ok