mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 08:13:21 +00:00
Fixed max slider when item limit is unlimited
This commit is contained in:
+10
-1
@@ -12,7 +12,7 @@ end)
|
||||
|
||||
-- extremely useful when restarting script mid-game
|
||||
Citizen.CreateThread(function()
|
||||
Citizen.Wait(20000) -- hopefully enough for connection to the SQL server
|
||||
Citizen.Wait(2000) -- hopefully enough for connection to the SQL server
|
||||
|
||||
if not hasSqlRun then
|
||||
LoadShop()
|
||||
@@ -26,6 +26,7 @@ function LoadShop()
|
||||
|
||||
local itemInformation = {}
|
||||
for i=1, #itemResult, 1 do
|
||||
|
||||
if itemInformation[itemResult[i].name] == nil then
|
||||
itemInformation[itemResult[i].name] = {}
|
||||
end
|
||||
@@ -39,6 +40,10 @@ function LoadShop()
|
||||
ShopItems[shopResult[i].store] = {}
|
||||
end
|
||||
|
||||
if itemInformation[shopResult[i].item].limit == -1 then
|
||||
itemInformation[shopResult[i].item].limit = 30
|
||||
end
|
||||
|
||||
table.insert(ShopItems[shopResult[i].store], {
|
||||
label = itemInformation[shopResult[i].item].label,
|
||||
item = shopResult[i].item,
|
||||
@@ -62,6 +67,8 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local sourceItem = xPlayer.getInventoryItem(itemName)
|
||||
|
||||
amount = ESX.Round(amount)
|
||||
|
||||
-- is the player trying to exploit?
|
||||
if amount < 0 then
|
||||
print('esx_shops: ' .. xPlayer.identifier .. ' attempted to exploit the shop!')
|
||||
@@ -71,6 +78,7 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
|
||||
-- get price
|
||||
local price = 0
|
||||
local itemLabel = ''
|
||||
|
||||
for i=1, #ShopItems[zone], 1 do
|
||||
if ShopItems[zone][i].item == itemName then
|
||||
price = ShopItems[zone][i].price
|
||||
@@ -78,6 +86,7 @@ AddEventHandler('esx_shops:buyItem', function(itemName, amount, zone)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
price = price * amount
|
||||
|
||||
-- can the player afford this item?
|
||||
|
||||
Reference in New Issue
Block a user