mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
+2
-6
@@ -25,10 +25,6 @@ function OpenShopMenu(zone)
|
||||
for i=1, #Config.Zones[zone].Items, 1 do
|
||||
local item = Config.Zones[zone].Items[i]
|
||||
|
||||
if item.limit == -1 then
|
||||
item.limit = 100
|
||||
end
|
||||
|
||||
table.insert(elements, {
|
||||
label = ('%s - <span style="color:green;">%s</span>'):format(item.label, _U('shop_item', ESX.Math.GroupDigits(item.price))),
|
||||
label_real = item.label,
|
||||
@@ -39,7 +35,7 @@ function OpenShopMenu(zone)
|
||||
value = 1,
|
||||
type = 'slider',
|
||||
min = 1,
|
||||
max = item.limit
|
||||
max = 100
|
||||
})
|
||||
end
|
||||
|
||||
@@ -166,4 +162,4 @@ Citizen.CreateThread(function()
|
||||
Citizen.Wait(500)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
+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