How to compare if a player has a weapon of that type
#1

Well, I have a system where you can have 4 different weapons. They're saved like weapon1, ammo1, weapon2,ammo2...

The problem is if I have like 3 weapons (deagle, m4, sniper) and I get an ak-47. The M4 get's swapped for ak-47 but in the script it's still there and the ak-47 saves on the 4. position (4. weapon slot in the user file). After that, I can't get any other weapon.


This is the code:

pawn Код:
public GivePlayerWeapons(senderid, playeridcheck, giveplayerweaponid)
{
    if(PlayerInfo[playeridcheck][Weapon1] == 0)
        {
            GivePlayerWeapon(playeridcheck, giveplayerweaponid, 100);
            PlayerInfo[playeridcheck][Weapon1] = giveplayerweaponid;
            return 1;
        }
    if(PlayerInfo[playeridcheck][Weapon2] == 0)
        {
            GivePlayerWeapon(playeridcheck, giveplayerweaponid, 100);
            PlayerInfo[playeridcheck][Weapon2] = giveplayerweaponid;
            return 1;
        }
    if(PlayerInfo[playeridcheck][Weapon3] == 0)
        {
            GivePlayerWeapon(playeridcheck, giveplayerweaponid, 100);
            PlayerInfo[playeridcheck][Weapon3] = giveplayerweaponid;
            return 1;
        }
    if(PlayerInfo[playeridcheck][Weapon4] == 0)
        {
            GivePlayerWeapon(playeridcheck, giveplayerweaponid, 100);
            PlayerInfo[playeridcheck][Weapon4] = giveplayerweaponid;
            return 1;
        }
       
    SendClientMessage(senderid, 0x935724, "That player can't hold anymore weapons");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)