How to convert number to Float? - 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: How to convert number to Float? (
/showthread.php?tid=665665)
How to convert number to Float? -
MichiCZ - 12.04.2019
Hello, i want to ask you, how to convert number to float.
Example:
In script i save PlayerInfo[playerid][Logic] = 100;
but few lines down i need to get Logic converted to float like 100.0
Any ideas how to do it?
Thanks!
// EDIT:
Found this, but didnt work
https://sampwiki.blast.hk/wiki/Float
Re: How to convert number to Float? -
BigETI - 12.04.2019
it is a function, just use it
Re: How to convert number to Float? -
NaS - 12.04.2019
float() should actually do it. How did you use it?
If you use the value inside a calculation, you do not really need to convert it yourself. The compiler will do it for you if you use it like this (for example):
Код:
new Float:some_float = PlayerInfo[playerid][Logic] * 55.0;
The compiler will convert Logic to Float automatically if the other value (55.0 in this case) is a Float already.
Otherwise use float(PlayerInfo[playerid][Logic]) instead.
Re: How to convert number to Float? -
MichiCZ - 12.04.2019
Quote:
Originally Posted by NaS
float() should actually do it. How did you use it?
If you use the value inside a calculation, you do not really need to convert it yourself. The compiler will do it for you if you use it like this (for example):
Код:
new Float:some_float = PlayerInfo[playerid][Logic] * 55.0;
The compiler will convert Logic to Float automatically if the other value (55.0 in this case) is a Float already.
Otherwise use float(PlayerInfo[playerid][Logic]) instead.
|
Works, thanks