Merge pull request #19 from ElPumpo/master

Fixed exploit: taking more than you can carry
This commit is contained in:
Don
2018-03-11 11:17:46 -07:00
committed by GitHub
4 changed files with 24 additions and 28 deletions
-9
View File
@@ -1,9 +0,0 @@
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
+1 -1
View File
@@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Property'
version '1.0.1'
version '1.0.2'
server_scripts {
'@es_extended/locale.lua',
+2
View File
@@ -29,5 +29,7 @@ Locales['en'] = {
['not_enough'] = 'you do not have enough money',
['invalid_quantity'] = 'invalid quantity',
['paid_rent'] = 'you ~g~paid~s~ your rent: ~g~$',
['not_enough_in_property'] = 'there\'s not enough of ~r~that item~w~ in the property!',
['player_cannot_hold'] = 'you do ~r~not~w~ have enough ~y~free space~w~ in your inventory!',
}
+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 + count) > 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