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

pawn Code:
new pWeapon[MAX_PLAYERS];

stock SetPlayerWeapon(playerid, weaponid, ammo)
{
    GivePlayerWeapon(playerid, weaponid, ammo);
    pWeapon[playerid] = weaponid;
    return 1;
}

public OnPlayerUpdate(playerid)
{
    if(GetPlayerWeapon(playerid) != pWeapon[playerid]) // If they changed weapon
    {
        SetPlayerArmedWeapon(playerid, pWeapon[playerid]); // Force their weapon back
    }
    return 1;
}
Do note though, if their ammo runs out it's going to call SetPlayerArmedWeapon constantly - a fix must be made for this.

To fix it, you would need to get the ammo using GetPlayerWeaponData, thus needing to get the slot for the weapon. If it's 0, don't force that weapon back.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)