random - 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 (
/showthread.php?tid=428357)
random -
speed258 - 05.04.2013
hi guys is any way to make random float numbers? as example 1.25 or 30.55 so i need random numbers from 0.99 to 50.99 is any way to make random float number?
Re: random -
RajatPawar - 05.04.2013
https://sampwiki.blast.hk/wiki/Useful_Functions#floatrand
Re: random -
speed258 - 05.04.2013
and how to add percent sight into text (%) and text will print hello you got 50% more money
Re: random -
MP2 - 05.04.2013
To insert a percentage sign you have to use %%.
As for floats, ****** made this:
pawn Код:
frandom(Float:max, Float:min = 0.0, dp = 4)
{
new
// Get the multiplication for storing fractional parts.
Float:mul = floatpower(10.0, dp),
// Get the max and min as integers, with extra dp.
imin = floatround(min * mul),
imax = floatround(max * mul);
// Get a random int between two bounds and convert it to a float.
return float(random(imax - imin) + imin) / mul;
}