mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
+5
-10
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user