Random Weapons Spawn
#1

I want players to spawn with random weapons (obviously one for each type, I can't have a M4 and an AK-47 at the same time), how can i do that?

Example:

The player spawns for the first time and receives Deagle, M4 and grenades. When he dies, he respawns and receives an Ak-47, a Deagle again and satchels.
Reply
#2

Just make a variable like Spawned so when you login its set to 1 than onplayerspawn if its set to one you use GivePlayerWeapon to give AK-47, Deagle and Satchels and if it isn't it'll give you a Deagle, M4, Grenades
Reply
#3

I had some free time. Here is a possible code:


At TOP of your script:

pawn Код:
new Spawn[MAX_PLAYERS];

At OnPlayerConnect:

pawn Код:
Spawn[playerid]=0;

At OnPlayerSpawn:

pawn Код:
ResetPlayerWeapons(playerid);
switch(Spawn[playerid])
{
case 0: { GivePlayerWeapon(playerid, 24, 100);
      GivePlayerWeapon(playerid, 25, 100);
      GivePlayerWeapon(playerid, 26, 100);
      Spawn[playerid]++;
    }
case 1: { GivePlayerWeapon(playerid, 27, 100);
      GivePlayerWeapon(playerid, 28, 100);
      GivePlayerWeapon(playerid, 29, 100);
      Spawn[playerid]++;
    }
case 2: { GivePlayerWeapon(playerid, 30, 100);
      GivePlayerWeapon(playerid, 31, 100);
      GivePlayerWeapon(playerid, 32, 100);
      Spawn[playerid]=0;  // The =0 MUST be at the LAST case.
    }
}

I did not test it, so if there are errors or bugs, please let me know.


EDIT: Indention is ****ed up cause I didn't write it at pawno.

Greetz,
Jeffry
Reply
#4

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
I had some free time. Here is a possible code:


At TOP of your script:

pawn Код:
new Spawn[MAX_PLAYERS];

At OnPlayerConnect:

pawn Код:
Spawn[playerid]=0;

At OnPlayerSpawn:

pawn Код:
ResetPlayerWeapons(playerid);
switch(Spawn[playerid])
{
case 0: { GivePlayerWeapon(playerid, 24, 100);
      GivePlayerWeapon(playerid, 25, 100);
      GivePlayerWeapon(playerid, 26, 100);
      Spawn[playerid]++;
    }
case 1: { GivePlayerWeapon(playerid, 27, 100);
      GivePlayerWeapon(playerid, 28, 100);
      GivePlayerWeapon(playerid, 29, 100);
      Spawn[playerid]++;
    }
case 2: { GivePlayerWeapon(playerid, 30, 100);
      GivePlayerWeapon(playerid, 31, 100);
      GivePlayerWeapon(playerid, 32, 100);
      Spawn[playerid]=0;  // The =0 MUST be at the LAST case.
    }
}

I did not test it, so if there are errors or bugs, please let me know.


EDIT: Indention is ****ed up cause I didn't write it at pawno.

Greetz,
Jeffry
It worked without any kind of errors, thanks a lot
Reply
#5

Quote:
Originally Posted by Freddy Z
Посмотреть сообщение
It worked without any kind of errors, thanks a lot
No problem. Have fun.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)