SA-MP Forums Archive
Random weapon and ammo - 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 weapon and ammo (/showthread.php?tid=566497)



Random weapon and ammo - Stoyanov - 06.03.2015

Код:
new warray[] = {16, 22, 24, 26, 27, 29, 31, 36, 38, 39};
new wp = random(sizeof(warray));
new amo = random(82);
GivePlayerWeapon(playerid, wp, amo);
"warray" is never used? !


Re: Random weapon and ammo - Vince - 06.03.2015

No it isn't. You use sizeof, which will simply return the size of the array (10). As a result you will you get a random value between 0 and 9 for the variable wp instead of an actual random value from the array.

pawn Код:
new wp = warray[random(sizeof(warray))];



Re: Random weapon and ammo - Stoyanov - 06.03.2015

Thanks REP++