mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Fixed exploit taking more than you can carry
This commit is contained in:
+21
-18
@@ -257,26 +257,29 @@ end)
|
||||
RegisterServerEvent('esx_property:getItem')
|
||||
AddEventHandler('esx_property:getItem', function(owner, type, item, count)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayerOwner = ESX.GetPlayerFromIdentifier(owner)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local xPlayerOwner = ESX.GetPlayerFromIdentifier(owner)
|
||||
|
||||
if type == 'item_standard' then
|
||||
if type == 'item_standard' then
|
||||
local sourceItem = xPlayer.getInventoryItem(item)
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayerOwner.identifier, function(inventory)
|
||||
|
||||
TriggerEvent('esx_addoninventory:getInventory', 'property', xPlayerOwner.identifier, function(inventory)
|
||||
|
||||
local roomItemCount = inventory.getItem(item).count
|
||||
|
||||
if roomItemCount >= count then
|
||||
inventory.removeItem(item, count)
|
||||
xPlayer.addInventoryItem(item, count)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('invalid_quantity'))
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
-- is there enough in the property?
|
||||
if count > 0 and inventory.getItem(item).count >= count then
|
||||
|
||||
-- can the player carry the said amount of x item?
|
||||
if sourceItem.limit ~= -1 and (sourceItem.count + item) > sourceItem.limit then
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold'))
|
||||
else
|
||||
inventory.removeItem(item, count)
|
||||
xPlayer.addInventoryItem(item, count)
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_in_property'))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if type == 'item_account' then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user