Merge pull request #663 from Taavi-AU/main

more context implementation
This commit is contained in:
Benzo
2022-11-13 22:06:17 +01:00
committed by GitHub
5 changed files with 186 additions and 185 deletions
+26 -30
View File
@@ -3,19 +3,16 @@ local LastZone, CurrentAction, CurrentActionMsg
local CurrentActionData = {}
function OpenAccessoryMenu()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'set_unset_accessory', {
title = TranslateCap('set_unset'),
align = 'top-left',
elements = {
{label = TranslateCap('helmet'), value = 'Helmet'},
{label = TranslateCap('ears'), value = 'Ears'},
{label = TranslateCap('mask'), value = 'Mask'},
{label = TranslateCap('glasses'), value = 'Glasses'}
}}, function(data, menu)
menu.close()
SetUnsetAccessory(data.current.value)
end, function(data, menu)
menu.close()
local elements = {
{unselectable = true, icon = "fas fa-user", title = TranslateCap('set_unset')},
{icon = "fas fa-hat-cowboy", title = TranslateCap("helmet"), value = "Helmet"},
{icon = "fas fa-deaf", title = TranslateCap("ears"), value = "Ears"},
{icon = "fas fa-mask", title = TranslateCap("mask"), value = "Mask"},
{icon = "fas fa-glasses", title = TranslateCap("glasses"), value = "Glasses"}
}
ESX.OpenContext("right", elements, function(menu,element)
SetUnsetAccessory(element.value)
end)
end
@@ -56,24 +53,24 @@ function OpenShopMenu(accessory)
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
menu.close()
menu.close()
local elements = {
{unselectable = true, icon = "fas fa-check-double", title = TranslateCap('valid_purchase')},
{icon = "fas fa-check-circle", title = TranslateCap("yes", ESX.Math.GroupDigits(Config.Price)), value = "yes"},
{icon = "fas fa-window-close", title = TranslateCap("no"), value = "no"}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = TranslateCap('valid_purchase'),
align = 'top-left',
elements = {
{label = TranslateCap('no'), value = 'no'},
{label = TranslateCap('yes', ESX.Math.GroupDigits(Config.Price)), value = 'yes'}
}}, function(data, menu)
menu.close()
if data.current.value == 'yes' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "yes" then
ESX.TriggerServerCallback('esx_accessories:checkMoney', function(hasEnoughMoney)
if hasEnoughMoney then
ESX.CloseContext()
TriggerServerEvent('esx_accessories:pay')
TriggerEvent('skinchanger:getSkin', function(skin)
TriggerServerEvent('esx_accessories:save', skin, accessory)
end)
else
ESX.CloseContext()
local player = PlayerPedId()
TriggerEvent('esx_skin:getLastSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
@@ -90,9 +87,7 @@ function OpenShopMenu(accessory)
ESX.ShowNotification(TranslateCap('not_enough_money'))
end
end)
end
if data.current.value == 'no' then
elseif element.value == "no" then
local player = PlayerPedId()
TriggerEvent('esx_skin:getLastSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
@@ -106,12 +101,13 @@ function OpenShopMenu(accessory)
elseif accessory == "Glasses" then
SetPedPropIndex(player, 1, -1, 0, 0)
end
ESX.CloseContext()
end
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = {}
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'shop_menu'
CurrentActionMsg = TranslateCap('press_access')
CurrentActionData = {}
@@ -131,7 +127,7 @@ AddEventHandler('esx_accessories:hasEnteredMarker', function(zone)
end)
AddEventHandler('esx_accessories:hasExitedMarker', function(zone)
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
CurrentAction = nil
end)
@@ -235,4 +231,4 @@ if Config.EnableControls then
end)
RegisterKeyMapping("accessory", "Open Accessory Menu", "keyboard", "k")
end
end
+23 -26
View File
@@ -18,20 +18,20 @@ function startScenario(anim)
end
function OpenAnimationsMenu()
local elements = {}
local elements = {
{unselectable = true, icon = "fas fa-smile", title = "Animations"}
}
for i=1, #Config.Animations, 1 do
table.insert(elements, {label = Config.Animations[i].label, value = Config.Animations[i].name})
elements[#elements+1] = {
icon = "fas fa-smile",
title = Config.Animations[i].label,
value = Config.Animations[i].name
}
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'animations', {
title = 'Animations',
align = 'top-left',
elements = elements
}, function(data, menu)
OpenAnimationsSubMenu(data.current.value)
end, function(data, menu)
menu.close()
ESX.OpenContext("right", elements, function(menu,element)
OpenAnimationsSubMenu(element.value)
end)
end
@@ -40,30 +40,29 @@ function OpenAnimationsSubMenu(menu)
local elements = {}
for i=1, #Config.Animations, 1 do
elements = {
{unselectable = true, icon = "fas fa-smile", title = Config.Animations[i].label}
}
if Config.Animations[i].name == menu then
title = Config.Animations[i].label
for j=1, #Config.Animations[i].items, 1 do
table.insert(elements, {
label = Config.Animations[i].items[j].label,
type = Config.Animations[i].items[j].type,
elements[#elements+1] = {
icon = "fas fa-smile",
title = Config.Animations[i].items[j].label,
type = Config.Animations[i].items[j].type,
value = Config.Animations[i].items[j].data
})
}
end
break
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'animations_sub', {
title = title,
align = 'top-left',
elements = elements
}, function(data, menu)
local type = data.current.type
local lib = data.current.value.lib
local anim = data.current.value.anim
ESX.OpenContext("right", elements, function(menu,element)
local type = element.type
local lib = element.value.lib
local anim = element.value.anim
if type == 'scenario' then
startScenario(anim)
@@ -72,8 +71,6 @@ function OpenAnimationsSubMenu(menu)
elseif type == 'anim' then
startAnim(lib, anim)
end
end, function(data, menu)
menu.close()
end)
end
+101 -87
View File
@@ -12,53 +12,35 @@ end)
function OpenBankActionsMenu()
local elements = {
{label = TranslateCap('customers'), value = 'customers'},
{label = TranslateCap('billing'), value = 'billing'}
{unselectable = true, icon = "fas fa-bank", title = TranslateCap("bank")},
{icon = "fas fa-users", title = TranslateCap("customers"), value = "customers"},
{icon = "fas fa-scroll", title = TranslateCap("billing"), value = "billing"}
}
if ESX.PlayerData.job.grade_name == 'boss' then
table.insert(elements, { label = TranslateCap('boss_actions'), value = 'boss_actions' })
elements[#elements+1] = {
icon = "fas fa-wallet",
title = TranslateCap("boss_actions"),
value = "boss_actions"
}
end
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'bank_actions', {
title = TranslateCap('bank'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.value == 'customers' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "customers" then
OpenCustomersMenu()
elseif data.current.value == 'billing' then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'billing', {
title = TranslateCap('bill_amount')
}, function(data, menu)
local amount = tonumber(data.value)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu.close()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer == -1 or closestDistance > 5.0 then
ESX.ShowNotification(TranslateCap('no_player_nearby'))
else
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_banker', 'Banque', amount)
end
end
end, function(data, menu)
elseif element.value == "billing" then
CreateBillingDialog()
elseif element.value == "boss_actions" then
TriggerEvent('esx_society:openBossMenu', 'banker', function(data, menu)
menu.close()
end)
elseif data.current.value == 'boss_actions' then
TriggerEvent('esx_society:openBossMenu', 'banker', function (data, menu)
menu.close()
end, {wash = false})
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end
end, function(data, menu)
menu.close()
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
@@ -68,69 +50,101 @@ end
function OpenCustomersMenu()
ESX.TriggerServerCallback('esx_bankerjob:getCustomers', function(customers)
local elements = {
head = { TranslateCap('customer'), TranslateCap('balance'), TranslateCap('actions') },
rows = {}
{unselectable = true, icon = "fas fa-users", title = TranslateCap('customer')}
}
for i=1, #customers do
table.insert(elements.rows, {
data = customers[i],
cols = {
customers[i].name,
customers[i].bankSavings,
'{{' .. TranslateCap('deposit') .. '|deposit}} {{' .. TranslateCap('withdraw') .. '|withdraw}}'
}
})
elements[#elements+1] = {
icon = "fas fa-user",
title = customers[i].name,
bankSavings = customers[i].bankSavings,
data = customers[i]
}
end
ESX.UI.Menu.Open('list', GetCurrentResourceName(), 'customers', elements, function(data, menu)
local customer = data.data
ESX.OpenContext("right", elements, function(menu,element)
local elements2 = {
{unselectable = true, icon = "fas fa-user", title = element.title},
{unselectable = true, icon = "fas fa-wallet", title = "$"..ESX.Math.GroupDigits(element.bankSavings)},
{icon = "fas fa-wallet", title = TranslateCap('deposit'), value = "deposit"},
{icon = "fas fa-wallet", title = TranslateCap('withdraw'), value = "withdraw"},
}
ESX.OpenContext("right", elements2, function(menu2,element2)
local customer = element.data
if element2.value == "deposit" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_deposit_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
if data.value == 'deposit' then
menu.close()
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_deposit_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu2.close()
TriggerServerEvent('esx_bankerjob:customerDeposit', customer.source, amount)
ESX.ShowNotification("You have deposited $"..amount.." into "..element.title.."s account.")
OpenCustomersMenu()
end
end, function(data2, menu2)
menu2.close()
TriggerServerEvent('esx_bankerjob:customerDeposit', customer.source, amount)
OpenCustomersMenu()
end
end, function(data2, menu2)
menu2.close()
OpenCustomersMenu()
end)
elseif data.value == 'withdraw' then
menu.close()
end)
elseif element2.value == "withdraw" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_withdraw_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'customer_withdraw_amount', {
title = TranslateCap('amount')
}, function(data2, menu2)
local amount = tonumber(data2.value)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu2.close()
TriggerServerEvent('esx_bankerjob:customerWithdraw', customer.source, amount)
ESX.ShowNotification("You have withdrawn $"..amount.." from "..element.title.."s account.")
OpenCustomersMenu()
end
end, function(data2, menu2)
menu2.close()
TriggerServerEvent('esx_bankerjob:customerWithdraw', customer.source, amount)
OpenCustomersMenu()
end
end, function(data2, menu2)
menu2.close()
OpenCustomersMenu()
end)
end
end, function(data, menu)
menu.close()
end)
end
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end)
end, function(menu)
CurrentAction = 'bank_actions_menu'
CurrentActionMsg = TranslateCap('press_input_context_to_open_menu')
CurrentActionData = {}
end)
end)
end
function CreateBillingDialog()
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'billing', {
title = TranslateCap('bill_amount')
}, function(data, menu)
local amount = tonumber(data.value)
if amount == nil then
ESX.ShowNotification(TranslateCap('invalid_amount'))
else
menu.close()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
if closestPlayer == -1 or closestDistance > 5.0 then
ESX.ShowNotification(TranslateCap('no_player_nearby'))
else
TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_banker', 'Bank', amount)
end
end
end, function(data, menu)
menu.close()
end)
end
AddEventHandler('esx_bankerjob:hasEnteredMarker', function (zone)
if zone == 'BankActions' and ESX.PlayerData.job and ESX.PlayerData.job.name == 'banker' then
CurrentAction = 'bank_actions_menu'
@@ -141,7 +155,7 @@ end)
AddEventHandler('esx_bankerjob:hasExitedMarker', function (zone)
CurrentAction = nil
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
end)
-- Create Blips
@@ -228,4 +242,4 @@ AddEventHandler('esx_phone:loaded', function (phoneNumber, contacts)
}
TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon)
end)
end)
+14 -15
View File
@@ -6,18 +6,17 @@ function OpenShopMenu()
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
menu.close()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = TranslateCap('valid_purchase'),
align = 'top-left',
elements = {
{label = TranslateCap('no'), value = 'no'},
{label = TranslateCap('yes'), value = 'yes'}
}}, function(data, menu)
menu.close()
local elements = {
{unselectable = true, icon = "fas fa-check-double", title = TranslateCap("valid_purchase")},
{icon = "fas fa-check-circle", title = TranslateCap("yes"), value = "yes"},
{icon = "fas fa-window-close", title = TranslateCap("no"), value = "no"},
}
if data.current.value == 'yes' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "yes" then
ESX.TriggerServerCallback('esx_barbershop:checkMoney', function(hasEnoughMoney)
if hasEnoughMoney then
ESX.CloseContext()
TriggerEvent('skinchanger:getSkin', function(skin)
TriggerServerEvent('esx_skin:save', skin)
end)
@@ -25,6 +24,7 @@ function OpenShopMenu()
TriggerServerEvent('esx_barbershop:pay')
hasPaid = true
else
ESX.CloseContext()
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
@@ -32,16 +32,15 @@ function OpenShopMenu()
ESX.ShowNotification(TranslateCap('not_enough_money'))
end
end)
elseif data.current.value == 'no' then
elseif element.value == "no" then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
ESX.CloseContext()
end
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_access')
end, function(data, menu)
menu.close()
end, function(menu)
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_access')
end)
@@ -82,7 +81,7 @@ AddEventHandler('esx_barbershop:hasEnteredMarker', function(zone)
end)
AddEventHandler('esx_barbershop:hasExitedMarker', function(zone)
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
currentAction = nil
if not hasPaid then
@@ -161,4 +160,4 @@ CreateThread(function()
Wait(500)
end
end
end)
end)
+22 -27
View File
@@ -8,16 +8,14 @@ function OpenShopMenu()
TriggerEvent('esx_skin:openRestrictedMenu', function(data, menu)
menu.close()
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', {
title = TranslateCap('valid_this_purchase'),
align = 'top-left',
elements = {
{label = TranslateCap('no'), value = 'no'},
{label = TranslateCap('yes'), value = 'yes'}
}}, function(data, menu)
menu.close()
local elements = {
{unselectable = true, icon = "fas fa-check-double", title = TranslateCap("valid_this_purchase")},
{icon = "fas fa-check-circle", title = TranslateCap("yes"), value = "yes"},
{icon = "fas fa-window-close", title = TranslateCap("no"), value = "no"},
}
if data.current.value == 'yes' then
ESX.OpenContext("right", elements, function(menu,element)
if element.value == "yes" then
ESX.TriggerServerCallback('esx_clotheshop:buyClothes', function(bought)
if bought then
TriggerEvent('skinchanger:getSkin', function(skin)
@@ -25,56 +23,53 @@ function OpenShopMenu()
end)
hasPaid = true
ESX.TriggerServerCallback('esx_clotheshop:checkPropertyDataStore', function(foundStore)
if foundStore then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'save_dressing', {
title = TranslateCap('save_in_dressing'),
align = 'top-left',
elements = {
{label = TranslateCap('no'), value = 'no'},
{label = TranslateCap('yes'), value = 'yes'}
}}, function(data2, menu2)
menu2.close()
local elements2 = {
{unselectable = true, icon = "fas fa-check-double", title = TranslateCap('save_in_dressing')},
{icon = "fas fa-check-circle", title = TranslateCap("yes"), value = "yes"},
{icon = "fas fa-window-close", title = TranslateCap("no"), value = "no"},
}
if data2.current.value == 'yes' then
ESX.OpenContext("right", elements2, function(menu2,element2)
if element2.value == "yes" then
ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'outfit_name', {
title = TranslateCap('name_outfit')
}, function(data3, menu3)
menu3.close()
TriggerEvent('skinchanger:getSkin', function(skin)
ESX.CloseContext()
TriggerServerEvent('esx_clotheshop:saveOutfit', data3.value, skin)
ESX.ShowNotification(TranslateCap('saved_outfit'))
end)
end, function(data3, menu3)
menu3.close()
end)
elseif element2.value == "no" then
ESX.CloseContext()
end
end)
end
end)
else
ESX.CloseContext()
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
ESX.ShowNotification(TranslateCap('not_enough_money'))
end
end)
elseif data.current.value == 'no' then
elseif element.value == "no" then
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
ESX.CloseContext()
end
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_menu')
currentActionData = {}
end, function(data, menu)
menu.close()
end, function(menu)
currentAction = 'shop_menu'
currentActionMsg = TranslateCap('press_menu')
currentActionData = {}
@@ -107,7 +102,7 @@ AddEventHandler('esx_clotheshop:hasEnteredMarker', function(zone)
end)
AddEventHandler('esx_clotheshop:hasExitedMarker', function(zone)
ESX.UI.Menu.CloseAll()
ESX.CloseContext()
currentAction = nil
if not hasPaid then