can set player ammo
#1

So I'm using this code:
pawn Code:
ammo = GetPlayerAmmo(playerid);
amount = 100;
new total = ammo - amount;
SetPlayerAmmo(playerid, GetWeaponSlot(playerid, GetPlayerWeapon(playerid)), total);
And why I can't set ammo for current player selected weapon with this code? Player ammo doesn't changes

GetWeaponSlot:
pawn Code:
stock GetWeaponSlot(playerid,weapon)
{
    new weid,ammo;

    for(new slot=0; slot < 13; slot++)
    {
        new slotas;
        GetPlayerWeaponData(playerid,slotas,weid,ammo);
        if(weid == weapon)
        {
            return slotas;
        }
    }
    return -1;
}
Reply
#2

If in doubt, read the wiki.

https://sampwiki.blast.hk/wiki/SetPlayerAmmo

Weaponid, not slotid.
Reply
#3

Quote:
Originally Posted by Vince
View Post
If in doubt, read the wiki.

https://sampwiki.blast.hk/wiki/SetPlayerAmmo

Weaponid, not slotid.
Damn, I am enabled "Function parameters hint on input", and there was weaponslot second parameter as hint, but now I see that it's wrong. Thanks for help!
Reply
#4

setplayerammo doesn't work
use giveplayerweapon
Reply
#5

Quote:
Originally Posted by sampreader
View Post
setplayerammo doesn't work
use giveplayerweapon
No, it works, at least for me.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)