SA-MP Forums Archive
Comparing value of a string with another number - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Comparing value of a string with another number (/showthread.php?tid=387691)



Comparing value of a string with another number - GTXcube - 25.10.2012

Hello. I need to compare a string I get (player Z position) with number from text file. How can i do that ? I know how to get Z distance and too how to get number from the file but i don't know how to compare them. Thanks for help


Re: Comparing value of a string with another number - mamorunl - 25.10.2012

Since when is a Z position saved in a String? You can just compare them with if(val1==val2) (unless it really is a String. Then just use floatval() or strval() I can't remember. In PHP it is floatval())


Re: Comparing value of a string with another number - ReneG - 25.10.2012

Adding to the above post, it's floatstr()

pawn Код:
new string[7] = "345.534"

printf("%f", floatstr(string));
prints out
Код:
345.534



Re: Comparing value of a string with another number - GTXcube - 26.10.2012

After many tries I always can't do it so I exacly explain what i want to do. I want to get value of player altitude. I use iparachute include found here: https://sampforum.blast.hk/showthread.php?tid=356826
So to get altitude i use
Код:
GetPlayerAltitude(playerid)
Then I need to compare it with value from my file and to get info from my file i use
Код:
dUserINT(Name(playerid)).("Lowest");
Values in my file is just integers. And after that all if the condition is met I want to type it to the file. For that I use this
Код:
dUserSetINT(Name(playerid)).("Lowest", VALUE HERE);
I want to compare it like, if is altitude smaller than value from the file, then write it to the file. If somebody care about include i use to read and write, tell me. Thanks for your reply


Re: Comparing value of a string with another number - GTXcube - 26.10.2012

aha, now im absolutly lost. Is another way to do it ?


Re: Comparing value of a string with another number - GTXcube - 27.10.2012

nobody ? :/