random number between two numbers - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: random number between two numbers (
/showthread.php?tid=216093)
random number between two numbers -
Davidovich - 24.01.2011
I've seen on wiki the random function but it only has the "max" parameter, so it would generate a number between 0 and "max-1".
how can I generate a random number between two numbers? Like 5 and 10.... it would generate 5, 6, 7, 8, 9 or 10.
Re: random number between two numbers -
Fj0rtizFredde - 24.01.2011
Like this?
pawn Код:
stock randomEx(min, max)
{
//Credits to ******
new rand = random(max-min)+min;
return rand;
}
Re: random number between two numbers -
Davidovich - 24.01.2011
Quote:
Originally Posted by Fj0rtizFredde
Like this?
pawn Код:
stock randomEx(min, max) { //Credits to ****** new rand = random(max-min)+min; return rand; }
|
hm
looks nice, lol, thanks
I would use like this?
Код:
new A = randomEx(5,10);
And, it would generate 5 and 10 or only 6, 7, 8 and 9?
Re: random number between two numbers -
Fj0rtizFredde - 24.01.2011
Yes use it like that
And Im not sure about if its 5-9 or 5-10 cant remember :/ Try it and you will find out
Re: random number between two numbers -
Gabe - 24.01.2011
It would generate 5-9
Re: random number between two numbers -
Davidovich - 24.01.2011
ok thank you all