Add support for new ESX weight system (#63)

* Added weight support

* Update main.lua

* Removed unused variable
This commit is contained in:
Poggu
2019-11-13 21:46:48 +01:00
committed by Samuel
parent 13da795b09
commit e8f98e03eb
7 changed files with 38 additions and 39 deletions
+7 -8
View File
@@ -262,21 +262,20 @@ AddEventHandler('esx_mechanicjob:getStockItem', function(itemName, count)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mechanic', function(inventory)
local item = inventory.getItem(itemName)
local sourceItem = xPlayer.getInventoryItem(itemName)
-- is there enough in the society?
if count > 0 and 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', xPlayer.source, _U('player_cannot_hold'))
else
if xPlayer.canCarryItem(itemName, count) then
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn', count, item.label))
xPlayer.showNotification(_U('have_withdrawn', count, item.label))
else
xPlayer.showNotification(_U('player_cannot_hold'))
end
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_quantity'))
xPlayer.showNotification(_U('invalid_quantity'))
end
end)
end)
@@ -299,10 +298,10 @@ AddEventHandler('esx_mechanicjob:putStockItems', function(itemName, count)
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_quantity'))
xPlayer.showNotification(_U('invalid_quantity'))
end
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_deposited', count, item.label))
xPlayer.showNotification(_U('have_deposited', count, item.label))
end)
end)