Fixed ammo bug

Fixed the famous ammo bug where if you remove a weapon from your inventory, it doesn't remove the ammo for it.
This commit is contained in:
ElPumpo
2018-03-17 18:11:16 +01:00
parent 9917ac369b
commit aacc2d1083
+2 -1
View File
@@ -170,6 +170,7 @@ AddEventHandler('esx:addWeapon', function(weaponName, ammo)
local weaponHash = GetHashKey(weaponName)
GiveWeaponToPed(playerPed, weaponHash, ammo, false, false)
SetPedAmmo(playerPed, weaponHash, ammo) -- remove leftover ammo
end)
RegisterNetEvent('esx:removeWeapon')
@@ -178,6 +179,7 @@ AddEventHandler('esx:removeWeapon', function(weaponName)
local weaponHash = GetHashKey(weaponName)
RemoveWeaponFromPed(playerPed, weaponHash)
SetPedAmmo(playerPed, weaponHash, 0) -- remove leftover ammo
end)
-- Commands
@@ -337,7 +339,6 @@ AddEventHandler('esx:pickupWeapon', function(weaponPickup, weaponName,ammo)
local ped = GetPlayerPed(-1)
local playerPedPos = GetEntityCoords(ped, true)
print(ammo)
CreateAmbientPickup(GetHashKey(weaponPickup), playerPedPos.x + 2.0, playerPedPos.y, playerPedPos.z + 0.5, 0, ammo, 1, false, true)
end)