Ammunition of the player's current weapon
#1

How can I detect the player's current ammunition and the remaining ammunition to recharge the weapon? Example: "7/14", "7" are the bullets that the weapon currently has and '14' is the available ammunition that the weapon has at this moment to be able to recharge it.

I already used 'GetPlayerAmmo' and 'GetPlayerWeaponData' but both functions show the total number of bullets (which can be fired by the weapon + the refills).
Reply
#2

switching the weapon OnPlayerWeaponShot and using a variable to save ammo whenever you give them weapon or they buy it.
Reply
#3

Quote:
Originally Posted by ConnorW
Посмотреть сообщение
switching the weapon OnPlayerWeaponShot and using a variable to save ammo whenever you give them weapon or they buy it.
Is it the only way to do that?
Reply
#4

https://sampwiki.blast.hk/wiki/GetPlayerWeaponData
https://sampwiki.blast.hk/wiki/GetPlayerAmmo

If both of those functions give you the total ammunition per weapon, then for each weapon's total ammo divide it with the amount of rounds it can shoot per clip.

Deagle with 56 ammo, 7 rounds per clip: 56/7 = 8 clips remaining

If you don't get a whole number, then assume that:

Deagle with 52 ammo, 7 rounds per clip: 7.4285.. clips left = 7, ammo left = 0.4285... * 7 (rounds per clip, not the clips left) = 2.99 (round to 3)
Reply
#5

I'd rather opt to make it manually, as some weapons don't have a magazine, I mean maximum shots before reload, as the Shotgun Sniper Country Rifle etc. I'd've done something like that:

Код:
ReloadWeapon(playerid, weaponid, ammo)
{
    switch(weaponid)
    { 
        case 24: 
        {
            SetPlayerAmmo(playerid, weaponid, ammo + 7);
            magInfo[playerid][Deagle]--;
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)