Random Gun!!
#1

Hey, i want to make a command, Where you say /randgun and you get a random gun, one of these id guns:

24,25,26,27,28,29,30,31,36,37,38

So, any idea on how to do this? i asumed it would have sumin to do with

GivePlayerWeapon(playerid,*sumin goes here to do with Random number* ,200);

Lol, well i duno, so any help?
Reply
#2

pawn Код:
GivePlayerWeapon(playerid, random(38 - 24) + 24, 500);
http://forum.sa-mp.com/index.php?top...5123#msg555123

EDIT:
Or,

pawn Код:
new weapon = random(11);
switch(weapon)
{
    case 0: GivePlayerWeapon(playerid, 24, 500);
    case 1: GivePlayerWeapon(playerid, 25, 500);
    case 2: GivePlayerWeapon(playerid, 26, 500);
    case 3: GivePlayerWeapon(playerid, 27, 500);
    case 4: GivePlayerWeapon(playerid, 28, 500);
    case 5: GivePlayerWeapon(playerid, 29, 500);
    case 6: GivePlayerWeapon(playerid, 30, 500);
    case 7: GivePlayerWeapon(playerid, 31, 500);
    case 8: GivePlayerWeapon(playerid, 36, 500);
    case 9: GivePlayerWeapon(playerid, 37, 500);
    case 10: GivePlayerWeapon(playerid, 38, 500);
}
Reply
#3

Ain't array would be faster and more compact in script?
Reply
#4

I'm just putting down random ideas.

pawn Код:
new weapons[] =
{
    24,
    25,
    26,
    27,
    28,
    29,
    30,
    31,
    36,
    37,
    38
};

GivePlayerWeapon(playerid, weapons[random(11)], 500);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)