SA-MP Forums Archive
how to make a random command? - 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: how to make a random command? (/showthread.php?tid=167373)



how to make a random command? - pmk1 - 12.08.2010

hey people i'm posting to ask how i could do a random command, like that gives a weapon between defined ids

ex :

i type /random

it could give me the weapon id 21, 22,23,24,25,26,27,28,29 or 30

i though about :

if(strcmp(cmdtext, "/random", true) == 0)
{
new random { its here that i don't know what to do};
GivePlayerWeapon(playerid, random, 200);
return 1;
}


Re: how to make a random command? - Toribio - 12.08.2010

pawn Код:
if(strcmp(cmdtext, "/random", true) == 0)
{
    new values[] = {21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
    GivePlayerWeapon(playerid, values[random(sizeof values)], 200);
    return 1;
}