How to remove player's weapon?
#1

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:

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);
        }
    }
}
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?
Reply
#2

Where is senderid used?
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(3 <= i <= 7)
        {
            if(tmpweapammo > 0) {
                GivePlayerWeapon(playeridcheck, tmpweapid, -tmpweapammo); // << to remove a weapon ???
                GivePlayerWeapon(playeridcheck, giveplayerweaponid, 999);
            }
        }
        else
        {
            GivePlayerWeapon(playeridcheck, giveplayerweaponid, 999);
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)