24.01.2011, 20:26
Well, I am creating an RP game mode and I want to player be able to only hold 4 weapons on him (different types). I divided where which weapon slot would go. I have primary weapon, secondary, meelee, special. I made a function that when player is given a weapon it is supposed to check if the player has a weapon of that slot. But, when I give player a weapon, his old weapon (let's say M4) stays there, and he is given a new "primary" weapon (let's say a Sawn-Off).
Here's the code:
Also, how to make it if player has ammo in it he would get his weapon removed/replaced, and if not he would just get a new weapon?
Here's the code:
pawn Код:
public GivePlayerWeapons(senderid, playeridcheck, giveplayerweaponid)
{
for (new i = 0; i < 13; i++) // START THE LOOP TO CHECK WEAPONS
{
new tmpweapid, tmpweapammo;
GetPlayerWeaponData(playeridcheck, i, tmpweapid, tmpweapammo);
//FOR SLOT 1 - PRIMARY WEAPON
if(i == 3 || i == 4 || i == 5 || i == 6 || i == 7)
{
GivePlayerWeapon(playeridcheck, tmpweapid, 0); // << to remove a weapon ???
GivePlayerWeapon(playeridcheck, giveplayerweaponid, 999);
}
else
{
GivePlayerWeapon(playeridcheck, giveplayerweaponid, 999);
}
}
}