From 654b3b76653f08400e8cad740f7ee5b2b5fc4190 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 11 Mar 2018 16:35:22 +0100 Subject: [PATCH 1/2] Fixed exploit taking more than you can carry --- .editorconfig | 9 --------- __resource.lua | 2 +- locales/en.lua | 2 ++ server/main.lua | 39 +++++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 28 deletions(-) delete mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 41c2aaf2..00000000 --- a/.editorconfig +++ /dev/null @@ -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 \ No newline at end of file diff --git a/__resource.lua b/__resource.lua index bf4cc7b6..14b44010 100644 --- a/__resource.lua +++ b/__resource.lua @@ -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', diff --git a/locales/en.lua b/locales/en.lua index c61b1419..3d796192 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -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!', } diff --git a/server/main.lua b/server/main.lua index 852e47d0..558ef84b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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 From b8f06df97606c05e6d8cc6a6ee938f5a00403b54 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sun, 11 Mar 2018 19:06:55 +0100 Subject: [PATCH 2/2] Fixed counting error --- server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/main.lua b/server/main.lua index 558ef84b..889e72d8 100644 --- a/server/main.lua +++ b/server/main.lua @@ -269,7 +269,7 @@ AddEventHandler('esx_property:getItem', function(owner, type, item, count) 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 + if sourceItem.limit ~= -1 and (sourceItem.count + count) > sourceItem.limit then TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold')) else inventory.removeItem(item, count)