Random Float 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: Random Float Number (
/showthread.php?tid=664891)
Random Float Number -
qRazor - 14.03.2019
Hi, how i can get a float number from random? Like random(1) to get 0.52.
Re: Random Float Number -
Romz - 14.03.2019
https://forum.sa-mp.com/showpost.php...52&postcount=3
Re: Random Float Number -
d3Pedro - 14.03.2019
https://sampwiki.blast.hk/wiki/Floatround
Re: Random Float Number -
qRazor - 15.03.2019
Quote:
Originally Posted by ******
|
Thank you!
EDIT: I need a little help again.. how i can extract an integer from float? Floatround over 0.50 rounded to a value of 1, it's possible to make if i have a value of 0.99, the integer number to be 0?
Re: Random Float Number -
Kaliber - 15.03.2019
Just check the wiki:
https://sampwiki.blast.hk/wiki/Floatround
There you see, that you have diffrent rounding Methods:
https://sampwiki.blast.hk/wiki/Floatround_method
For example:
PHP код:
floatround(0.99, floatround_floor); //returns 0
Re: Random Float Number -
qRazor - 15.03.2019
Quote:
Originally Posted by Kaliber
|
I want to return a value from a variable, for example x = 0.99, or x = 0.12, or x = 0.51, you understand now? And x in this case to be 0.
Re: Random Float Number -
Kaliber - 15.03.2019
Yes dude, i understood that.
But it seems, you dont understand the use of a function, so read some basics:
https://sampwiki.blast.hk/wiki/Scripting_Basics
You just have to write:
PHP код:
floatround(x, floatround_floor);
Re: Random Float Number -
qRazor - 15.03.2019
Quote:
Originally Posted by Kaliber
|
Yeah it was my bad and thank you! I apologize again man.