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..889e72d8 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 + 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