Fixed max slider when item limit is unlimited

This commit is contained in:
ElPumpo
2018-07-11 12:16:58 +02:00
parent af3219663e
commit 538a97d3f3
3 changed files with 41 additions and 26 deletions
+4 -1
View File
@@ -19,6 +19,7 @@ client_scripts {
server_scripts {
'@es_extended/locale.lua',
'@mysql-async/lib/MySQL.lua',
'locales/de.lua',
'locales/br.lua',
'locales/en.lua',
@@ -26,7 +27,9 @@ server_scripts {
'locales/fr.lua',
'locales/es.lua',
'locales/sv.lua',
'@mysql-async/lib/MySQL.lua',
'config.lua',
'server/main.lua'
}
dependency 'es_extended'
+27 -24
View File
@@ -91,16 +91,16 @@ end)
-- Create Blips
Citizen.CreateThread(function()
for k,v in pairs(Config.Zones) do
for i = 1, #v.Pos, 1 do
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)
SetBlipSprite (blip, 52)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 1.0)
SetBlipColour (blip, 2)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(_U('shops'))
EndTextCommandSetBlipName(blip)
for i = 1, #v.Pos, 1 do
local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z)
SetBlipSprite (blip, 52)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 1.0)
SetBlipColour (blip, 2)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(_U('shops'))
EndTextCommandSetBlipName(blip)
end
end
end)
@@ -151,24 +151,27 @@ end)
-- Key Controls
Citizen.CreateThread(function()
while true do
Citizen.Wait(10)
if CurrentAction ~= nil then
while true do
Citizen.Wait(10)
SetTextComponentFormat('STRING')
AddTextComponentString(CurrentActionMsg)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
if CurrentAction ~= nil then
if IsControlJustReleased(0, 38) then
SetTextComponentFormat('STRING')
AddTextComponentString(CurrentActionMsg)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
if CurrentAction == 'shop_menu' then
OpenShopMenu(CurrentActionData.zone)
end
if IsControlJustReleased(0, 38) then
CurrentAction = nil
if CurrentAction == 'shop_menu' then
OpenShopMenu(CurrentActionData.zone)
end
end
CurrentAction = nil
end
end
end
else
Citizen.Wait(500)
end
end
end)
+10 -1
View File
@@ -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?