SA-MP Forums Archive
random() question - 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() question (/showthread.php?tid=597610)



random() question - Gazzy - 02.01.2016

Hello. I've got a question about the random() function.

If I have this:
Код:
new randomnumber = random(1, 4)
Does this mean "randomnumber" has the possibility to be either 1, 2, 3 or 4?
Or does it mean it has the possibility to be 2, 3, 4 or whatever? Thanks in advance


Re: random() question - Sebz - 02.01.2016

This may or may not be what you're trying to do, I'm not entirely sure how to pull it off myself.

Код:
new Float:Random[][] =
{
    1,
    2,
    3,
    4
};



Re: random() question - J4Rr3x - 02.01.2016

If you want min and max:
Код:
#define randomex(%0,%1) random(%0-%1)+%1



Re: random() question - SickAttack - 02.01.2016

The correct usage is "random(max)".

https://sampwiki.blast.hk/wiki/Random

The number has the possibility to be either 0, 1, 2 or 3 when 4 is placed as the substitution of "max".