SA-MP Forums Archive
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=600126)



random - CSCripMa - 04.02.2016

Hi,

I use now random like that

new randomnumber = random( 10 );

but i want to make that numbers bellow 5 : 6 7 8 9 make chance that they will be random is bigger than others it's possible?


Re: random - Lucky13 - 04.02.2016

I assume you want something like this, correct me if I'm wrong.

Код:
new firstrand = random(3)+1, secondrand;
if(firstrand == 1 || firstrand == 2) // 5, 6, 7, 8, 9 have 2/3 chances to come. ( 66.66% chances )
{
       secondrand = random(5)+5; // 5, 6, 7, 8, 9
}
else if(firstrand == 3) // 1, 2, 3, 4 have only 1/3 chances to come ( 33.33% chances )
{
       secondrand = random(4)+1; // 1, 2, 3, 4
}