mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-30 17:58:54 +00:00
Sync consumed ammo with server properly
No more security issues here!
This commit is contained in:
@@ -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
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user