mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
context implementation
This commit is contained in:
@@ -2,49 +2,39 @@ local hasAlreadyEnteredMarker, lastZone
|
|||||||
local currentAction, currentActionMsg, currentActionData = nil, nil, {}
|
local currentAction, currentActionMsg, currentActionData = nil, nil, {}
|
||||||
|
|
||||||
function OpenShopMenu(zone)
|
function OpenShopMenu(zone)
|
||||||
local elements = {}
|
local elements = {
|
||||||
|
{unselectable = true, icon = "fas fa-shopping-basket", title = TranslateCap('shop') }
|
||||||
|
}
|
||||||
|
|
||||||
for i=1, #Config.Zones[zone].Items, 1 do
|
for i=1, #Config.Zones[zone].Items, 1 do
|
||||||
local item = Config.Zones[zone].Items[i]
|
local item = Config.Zones[zone].Items[i]
|
||||||
|
|
||||||
table.insert(elements, {
|
elements[#elements+1] = {
|
||||||
label = ('%s - <span style="color:green;">%s</span>'):format(item.label, TranslateCap('shop_item', ESX.Math.GroupDigits(item.price))),
|
icon = "fas fa-shopping-basket",
|
||||||
|
title = ('%s - <span style="color:green;">%s</span>'):format(item.label, TranslateCap('shop_item', ESX.Math.GroupDigits(item.price))),
|
||||||
itemLabel = item.label,
|
itemLabel = item.label,
|
||||||
item = item.name,
|
item = item.name,
|
||||||
price = item.price,
|
price = item.price
|
||||||
|
}
|
||||||
-- menu properties
|
|
||||||
value = 1,
|
|
||||||
type = 'slider',
|
|
||||||
min = 1,
|
|
||||||
max = 100
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ESX.UI.Menu.CloseAll()
|
ESX.OpenContext("right", elements, function(menu,element)
|
||||||
|
local elements2 = {
|
||||||
|
{unselectable = true, icon = "fas fa-shopping-basket", title = element.title},
|
||||||
|
{icon = "fas fa-shopping-basket", title = "Amount", input = true, inputType = "number", inputPlaceholder = "Amount you want to buy", inputMin = 1, inputMax = 25},
|
||||||
|
{icon = "fas fa-check-double", title = "Confirm", val = "confirm"}
|
||||||
|
}
|
||||||
|
|
||||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', {
|
ESX.OpenContext("right", elements2, function(menu2,element2)
|
||||||
title = TranslateCap('shop'),
|
local amount = menu2.eles[2].inputValue
|
||||||
align = 'bottom-left',
|
ESX.CloseContext()
|
||||||
elements = elements
|
TriggerServerEvent('esx_shops:buyItem', element.item, amount, zone)
|
||||||
}, function(data, menu)
|
end, function(menu)
|
||||||
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
|
currentAction = 'shop_menu'
|
||||||
title = TranslateCap('shop_confirm', data.current.value, data.current.itemLabel, ESX.Math.GroupDigits(data.current.price * data.current.value)),
|
currentActionMsg = TranslateCap('press_menu')
|
||||||
align = 'bottom-left',
|
currentActionData = {zone = zone}
|
||||||
elements = {
|
|
||||||
{label = TranslateCap('no'), value = 'no'},
|
|
||||||
{label = TranslateCap('yes'), value = 'yes'}
|
|
||||||
}}, function(data2, menu2)
|
|
||||||
if data2.current.value == 'yes' then
|
|
||||||
TriggerServerEvent('esx_shops:buyItem', data.current.item, data.current.value, zone)
|
|
||||||
end
|
|
||||||
|
|
||||||
menu2.close()
|
|
||||||
end, function(data2, menu2)
|
|
||||||
menu2.close()
|
|
||||||
end)
|
end)
|
||||||
end, function(data, menu)
|
end, function(menu)
|
||||||
menu.close()
|
|
||||||
|
|
||||||
currentAction = 'shop_menu'
|
currentAction = 'shop_menu'
|
||||||
currentActionMsg = TranslateCap('press_menu')
|
currentActionMsg = TranslateCap('press_menu')
|
||||||
currentActionData = {zone = zone}
|
currentActionData = {zone = zone}
|
||||||
|
|||||||
Reference in New Issue
Block a user