SA-MP Forums Archive
A function like random/randomex(), but for floats. - 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: A function like random/randomex(), but for floats. (/showthread.php?tid=367534)



A function like random/randomex(), but for floats. - WooTFTW - 10.08.2012

I'm looking a random function for floats:
fRandom(230.4, 530.7);

Have anyone created a function like this?

I have this function, but it shows error. ((error in the comment)
pawn Код:
stock Float:fRandomEx(Float:min, Float:max) // function with tag result used before definition, forcing reparse
{
    return min+(max - min)*random(32768)/32768.0;
}



Re: A function like random/randomex(), but for floats. - playbox12 - 10.08.2012

Why not convert the float to an integer first? https://sampwiki.blast.hk/wiki/Floatround


Re: A function like random/randomex(), but for floats. - WooTFTW - 10.08.2012

Quote:
Originally Posted by playbox12
Посмотреть сообщение
Why not convert the float to an integer first? https://sampwiki.blast.hk/wiki/Floatround
Oh, yeah. Didn't think of that, thanks.