Weapons - 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: Weapons (
/showthread.php?tid=650104)
Weapons -
Matyaas - 20.02.2018
Hello people, sorry for my bad English but I'm using the ****** translator.
I wanted to know if you can create a command that removes the ammunition of a specific weapon, I explain:
I type the command / ammo deagle
and the bullets disappear from the Desert Eagle, shotgun, sniper, molotov, if you do not have that weapon, tell him an error message explaining that he does not have the gun or the bullets.
I hope you understand me, thank you.
Re: Weapons -
Mugala - 20.02.2018
Agh, I actually don't understand, sry, can u explain it better?
Re: Weapons -
RogueDrifter - 20.02.2018
https://sampwiki.blast.hk/wiki/SetPlayerAmmo
Re: Weapons -
Matyaas - 22.02.2018
how do I do that if I want to use / ammo 24 (24 = desert eagle id) is the other player and if you do not have that weapon do not let the function run?
Re: Weapons -
NaS - 22.02.2018
You need to use GetPlayerWeaponData to get weapon data about the weapon you want to remove, and to find out if that weapon is owned by the player.
Put it in a loop from 0 to (including) 11 (12 slots). It will give you the weapon ID and the ammo for that slot.
If the weaponid is the one you typed AND ammo isn't zero, remove that weapon by using SetPlayerAmmo and return.
If the loop finishes to execute, it was not found and you can send a failure message to the player.