Sync consumed ammo with server properly

No more security issues here!
This commit is contained in:
ElPumpo
2020-03-22 09:43:43 +01:00
parent ff9930068f
commit 9a1dfa42ca
4 changed files with 48 additions and 56 deletions
+10
View File
@@ -367,6 +367,16 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
end
self.updateWeaponAmmo = function(weaponName, ammoCount)
local loadoutNum, weapon = self.getWeapon(weaponName)
if weapon then
if ammoCount < weapon.ammo then
weapon.ammo = ammoCount
end
end
end
self.setWeaponTint = function(weaponName, weaponTintIndex)
local loadoutNum, weapon = self.getWeapon(weaponName)
+6 -3
View File
@@ -225,10 +225,13 @@ AddEventHandler('esx:updateCoords', function(coords)
end
end)
RegisterNetEvent('esx:updateLoadout')
AddEventHandler('esx:updateLoadout', function(loadout)
RegisterNetEvent('esx:updateWeaponAmmo')
AddEventHandler('esx:updateWeaponAmmo', function(weaponName, ammoCount)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.loadout = loadout
if xPlayer then
xPlayer.updateWeaponAmmo(weaponName, ammoCount)
end
end)
RegisterNetEvent('esx:giveInventoryItem')