Fixed exploit taking more than you can carry

This commit is contained in:
ElPumpo
2018-03-11 16:35:22 +01:00
parent 4fb2d8e1e0
commit 654b3b7665
4 changed files with 24 additions and 28 deletions
+21 -18
View File
@@ -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