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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random(); (/showthread.php?tid=231279)



Random(); - Typhome - 25.02.2011

Hello.

I'm making 3D label, but..
I want make it, system generates randomly plane number:
Like: LH-392, SF-382, OD-382....

new rand = random(??);
format(string,sizeof(string),"[PLANE: %s-%d]",rand?);

So how do it? Thanks. :3


Re: Random(); - cessil - 25.02.2011

well IRL planes are Dest ID - unique number. so it'd be LV SF or LS.
random(x); goes from 0 - x so if you wanted from 100 - 999 you would do min + random(max - min)

example
pawn Код:
switch(random(3))
{
    case 0: format(string,sizeof(string),"LV - ",100 + random(899));
    case 1: format(string,sizeof(string),"SF - ",100 + random(899));
    case 2: format(string,sizeof(string),"LS - ",100 + random(899));
}