SA-MP Forums Archive
Random Weapons Spawn - 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 Weapons Spawn (/showthread.php?tid=157744)



Random Weapons Spawn - Freddy Z - 07.07.2010

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.


Re: Random Weapons Spawn - MisterTickle - 07.07.2010

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


Re: Random Weapons Spawn - Jeffry - 08.07.2010

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


Re: Random Weapons Spawn - Freddy Z - 08.07.2010

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


Re: Random Weapons Spawn - Jeffry - 09.07.2010

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