can set player ammo - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: can set player ammo (
/showthread.php?tid=417600)
can set player ammo -
Daslee - 21.02.2013
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;
}
Re: can set player ammo -
Vince - 21.02.2013
If in doubt, read the wiki.
https://sampwiki.blast.hk/wiki/SetPlayerAmmo
Weaponid, not slotid.
Re: can set player ammo -
Daslee - 22.02.2013
Quote:
Originally Posted by Vince
|
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!
Re: can set player ammo -
sampreader - 22.02.2013
setplayerammo doesn't work
use giveplayerweapon
Re: can set player ammo -
Daslee - 26.02.2013
Quote:
Originally Posted by sampreader
setplayerammo doesn't work
use giveplayerweapon
|
No, it works, at least for me.