Restricting weapon slots
#1

Is there a way I could restrict weapon slots? What I mean is that I want only 3 weapon slots available for a player and the other slots restricted. So when a player go into the ammunation they can only purchase 3 weapons.
Reply
#2

Hmm, try and make a restriction when a player buys a weapon. Example:
pawn Код:
new BoughtWeps = 0;

CMD:buyweapon(playerid, params[]) {
if(BoughtWeps == 0) {
//buying weapon data
BoughtWeps++;
}
return 1;
}
Sorry, it might not work, i'm a little tired.
Reply
#3

Any 3 slots or specific ones? If specific then check this:

pawn Код:
// a stock to check whether a weapon id is valid or invalid
stock IsValidWeaponID(weaponid)
{
    if((weaponid > 0 && weaponid < 19) || (weaponid > 21 && weaponid < 47))
        return 1; // it's valid weapon id so return 1

    return 0; // Invalid return 0
}

stock AllowOnlyThreeSlotsForPlayer(playerid, slotid1, slotid2, slotid3) //
{
    new wepid[13], ammo[13];
    for(new i = 0; i < 13; i++)
    {
        GetPlayerWeaponData(playerid, i, wepid[i], ammo[i]);
        // the following code is supposed to check if a player has a wepaon in another slot than the three allowed slots
        // IsValidWeaponID(weapid[i]) == 1 - to check if a player has a weapon in this slot (i 0-13)
        // (i != slotid1 && i != slotid2 && i != slotid3) - if the slot id of the weapon ^  is not equal to any of the three slots
        if(IsValidWeaponID(weapid[i]) == 1 && (i != slotid1 && i != slotid2 && i != slotid3))
        {
            GivePlayerWeapon(playerid, weapid[i], -ammo[i]); // not sure if this would remove the weapon but it should
        }
    }
    return 1;
}
then you can put the AllowOnlyThreeSlotsForPlayer into a player for loop inside a repeatedly timer.
Reply
#4

Thank you both.

I think I have a understanding on how to go about it now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)