Fixed ammo duplicate on restoreLoadout, fixes #171

This commit is contained in:
ElPumpo
2018-12-23 12:21:28 +01:00
parent 9224f9119f
commit 37ada40b21
+8 -1
View File
@@ -94,12 +94,19 @@ end)
AddEventHandler('esx:restoreLoadout', function()
local playerPed = PlayerPedId()
local ammoTypes = {}
RemoveAllPedWeapons(playerPed, true)
for i=1, #ESX.PlayerData.loadout, 1 do
local weaponHash = GetHashKey(ESX.PlayerData.loadout[i].name)
GiveWeaponToPed(playerPed, weaponHash, ESX.PlayerData.loadout[i].ammo, false, false)
GiveWeaponToPed(playerPed, weaponHash, 0, false, false)
local ammoType = GetPedAmmoTypeFromWeapon(playerPed, weaponHash)
if not ammoTypes[ammoType] then
AddAmmoToPed(playerPed, weaponHash, ESX.PlayerData.loadout[i].ammo)
ammoTypes[ammoType] = true
end
end
LoadoutLoaded = true