Added weight support (#65)

* Added weight support
This commit is contained in:
Poggu
2019-10-19 19:35:54 +02:00
committed by Samuel
parent 18b16dea70
commit 4efea53b37
2 changed files with 7 additions and 16 deletions
+5 -10
View File
@@ -11,15 +11,10 @@ MySQL.ready(function()
ShopItems[shopResult[i].store] = {}
end
if shopResult[i].limit == -1 then
shopResult[i].limit = 30
end
table.insert(ShopItems[shopResult[i].store], {
label = shopResult[i].label,
item = shopResult[i].item,
price = shopResult[i].price,
limit = shopResult[i].limit
})
else
print(('esx_shops: invalid item "%s" found!'):format(shopResult[i].item))
@@ -63,15 +58,15 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
-- can the player afford this item?
if xPlayer.getMoney() >= price then
-- can the player carry the said amount of x item?
if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then
TriggerClientEvent('esx:showNotification', _source, _U('player_cannot_hold'))
else
if xPlayer.canCarryItem(itemName, amount) then
xPlayer.removeMoney(price)
xPlayer.addInventoryItem(itemName, amount)
TriggerClientEvent('esx:showNotification', _source, _U('bought', amount, itemLabel, ESX.Math.GroupDigits(price)))
xPlayer.showNotification(_U('bought', amount, itemLabel, ESX.Math.GroupDigits(price))
else
xPlayer.showNotification(_U('player_cannot_hold'))
end
else
local missingMoney = price - xPlayer.getMoney()
TriggerClientEvent('esx:showNotification', _source, _U('not_enough', ESX.Math.GroupDigits(missingMoney)))
xPlayer.showNotification(_U('not_enough', ESX.Math.GroupDigits(missingMoney))
end
end)