Problem with SetPlayerAmmo. - 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: Problem with SetPlayerAmmo. (
/showthread.php?tid=572859)
Problem with SetPlayerAmmo. -
Baltimore - 02.05.2015
Hi.
For exemple:
pawn Код:
SetPlayerAmmo(playerid, 5, 0);
It's not work...
I still have the weapon in hands ...
Re: Problem with SetPlayerAmmo. -
arlindi - 02.05.2015
ClickHere
Look this before
Re: Problem with SetPlayerAmmo. -
Baltimore - 02.05.2015
I already looked. I tried with the slot of the weapon, the id of the weapon, but it's not work.
Re: Problem with SetPlayerAmmo. -
arlindi - 02.05.2015
Where are you using this ?
Can you show mee the code ?
Re: Problem with SetPlayerAmmo. -
Mencent - 02.05.2015
PHP код:
SetPlayerAmmo(playerid, 5, 0);
5 is not the weapon id, but the slotid.
You have to use the weaponid, look here:
Quote:
weaponslot The ID of the weapon to set the ammo of. The name of this parameter is wrong - the weapon ID must be passed, not the slot
|
Re: Problem with SetPlayerAmmo. -
Baltimore - 02.05.2015
5 it's a weaponid lol.
https://sampwiki.blast.hk/wiki/Weapons
Re: Problem with SetPlayerAmmo. -
Mencent - 02.05.2015
Do you want delete your weapon or give an another weapon in the hands?
Re: Problem with SetPlayerAmmo. -
Baltimore - 02.05.2015
delete
Re: Problem with SetPlayerAmmo. -
Mencent - 02.05.2015
Take this function:
PHP код:
stock RemovePlayerWeapon(playerid, weaponid, ammo = 0) //©Jeffry
{
new w = GetPlayerWeapon(playerid), plyWeapons[13], plyAmmo[13];
for(new slot = 0; slot <= 12; slot++)
{
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
if(plyWeapons[slot] == weaponid)
{
if(ammo == 0 || plyAmmo[slot] <= ammo)
{
if(w == plyWeapons[slot]) w = 0;
plyAmmo[slot] = 0;
plyWeapons[slot] = 0;
}
else
{
plyAmmo[slot]-=ammo;
}
}
}
ResetPlayerWeapons(playerid);
for(new slot = 0; slot <= 12; slot++)
{
GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
}
SetPlayerArmedWeapon(playerid, w);
return 1;
}
and write it so:
PHP код:
RemovePlayerWeapon(playerid,5);