Getting the ammo value of an armed weapon.
#1

How could I get the ammo value of a player's armed weapon?

I need something that will work like this:
new ammo;
ammo = *ammo function here*


Thank you!
Reply
#2

Can you explain it better? I don't really understand it.
Reply
#3

. . .
How do I get the ammo value of a weapon?

Here is what I mean, script-wise. Of course GetWeaponAmmo is not an actual function.
new ammo;
ammo = GetWeaponAmmo;
Reply
#4

pawn Код:
new ammo = GetPlayerAmmo(playerid);
Simple
Reply
#5

Found it:
Quote:
Originally Posted by BigETI
Посмотреть сообщение
pawn Код:
#define INVALID_WEAPON_SLOT_ID -1
stock GetWeaponSlot(weaponid)
{
    new slot;
    switch(weaponid)
    {
        case 0,1: slot = 0;
        case 2..9: slot = 1;
        case 22..24: slot = 2;
        case 25..27: slot = 3;
        case 28,29,32: slot = 4;
        case 30,31: slot = 5;
        case 33,34: slot = 6;
        case 35..38: slot = 7;
        case 16..18,39: slot = 8;
        case 41..43: slot = 9;
        case 10..15: slot = 10;
        case 44..46: slot = 11;
        case 40: slot = 12;
        default: slot = INVALID_WEAPON_SLOT_ID;
    }
    return slot;
}

stock GetPlayerAmmoFromWeapon(playerid, weaponid)
{
    new weapon, ammo;
    GetPlayerWeaponData(playerid, GetWeaponSlot(weaponid), weapon, ammo);
    return ammo;
}
Edit:
new ammo = GetPlayerAmmo(playerid);

Thank you for this!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)