[Needed] Weapon will stay in hand untill stored away with a command.
#8

Quote:
Originally Posted by CyNiC
View Post
Another option is to disable the player slot by weapon id(give negative weapon ammo will disable your slot):

pawn Code:
TogglePlayerWeapons(playerid, bool:toggle, ...)
{
    new Args = numargs();

    if(!toggle)
    {
        for(new i = 0; i < 13; i++)
        {
            GetPlayerWeaponData(playerid, i, PlayerWeapons[playerid][0][i], PlayerWeapons[playerid][1][i]);
            for(new arg = 2; arg < Args; arg++)
            {
                if(PlayerWeapons[playerid][0][i] == getarg(arg))
                {
                    GivePlayerWeapon(playerid, PlayerWeapons[playerid][0][i], - (PlayerWeapons[playerid][1][i] * 2));
                    continue;
                }
            }
        }
    }
    else
    {
        ResetPlayerWeapons(playerid);
        for(new i = 0; i < 13; i++)
        {
            GetPlayerWeaponData(playerid, i, PlayerWeapons[playerid][0][i], PlayerWeapons[playerid][1][i]);
            for(new arg = 2; arg < Args; arg++)
            {
                if(PlayerWeapons[playerid][1][i] < 0 && PlayerWeapons[playerid][0][i] == getarg(arg))
                {
                    PlayerWeapons[playerid][1][i] -= (PlayerWeapons[playerid][1][i] * 2);
                }
            }            
            GivePlayerWeapon(playerid, PlayerWeapons[playerid][0][i], PlayerWeapons[playerid][1][i]);
        }
    }
    return 1;
}

GivePlayerWeaponEx(playerid, weaponid, ammo)
{
    GivePlayerWeapon(playerid, weaponid, ammo);
    PlayerWeapons[playerid][1][GetWeaponSlot(weaponid)] += ammo;
}

stock GetWeaponSlot(weaponid)
{
    switch (weaponid)
    {
        case  0,      1: return  0; // Unarmed
        case  2  ..   9: return  1; // Melee
        case 22  ..  24: return  2; // Pistol
        case 25  ..  27: return  3; // Shotgun
        case 28, 29, 32: return  4; // SMG
        case 30,     31: return  5; // Machinegun
        case 33,     34: return  6; // Rifle
        case 35  ..  38: return  7; // Heavy
        case 16, 18, 39: return  8; // Projectile
        case 42,     43: return  9; // Special
        case 14        : return 10; // Gifts
        case 44  ..  46: return 11; // Special
        case 40        : return 12; // Detonator
    }
    return 0;
}
Remember to replace all GivePlayerWeapon for GivePlayerWeaponEx.

pawn Code:
//Example

//Disable Deagle:
TogglePlayerWeapons(playerid, false, 24);
//Enable Deagle and disable MP5 and M4:
TogglePlayerWeapons(playerid, false, 29, 31);
TogglePlayerWeapons(playerid, true, 24);
I don't get it. Where i need to put this stack? O.o
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)