mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
Fix typo + Add complete boss menu
This commit is contained in:
+381
-3
@@ -31,6 +31,380 @@ function UpdateSocietyMoneyHUDElement(money)
|
||||
|
||||
end
|
||||
|
||||
function OpenBossMenu(society, close, options)
|
||||
|
||||
local options = options or {}
|
||||
local elements = {}
|
||||
|
||||
local defaultOptions = {
|
||||
withdraw = true,
|
||||
deposit = true,
|
||||
wash = true,
|
||||
employees = true,
|
||||
grades = true
|
||||
}
|
||||
|
||||
for k,v in pairs(defaultOptions) do
|
||||
if options[k] == nil then
|
||||
options[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
if options.withdraw then
|
||||
table.insert(elements, {label = _U('withdraw_society_money'), value = 'withdraw_society_money'})
|
||||
end
|
||||
|
||||
if options.deposit then
|
||||
table.insert(elements, {label = _U('deposit_society_money'), value = 'deposit_money'})
|
||||
end
|
||||
|
||||
if options.wash then
|
||||
table.insert(elements, {label = _U('wash_money'), value = 'wash_money'})
|
||||
end
|
||||
|
||||
if options.employees then
|
||||
table.insert(elements, {label = _U('employee_management'), value = 'manage_employees'})
|
||||
end
|
||||
|
||||
if options.grades then
|
||||
table.insert(elements, {label = _U('salary_management'), value = 'manage_grades'})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'boss_actions_' .. society,
|
||||
{
|
||||
title = 'Patron',
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
if data.current.value == 'withdraw_society_money' then
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'withdraw_society_money_amount_' .. society,
|
||||
{
|
||||
title = _U('withdraw_amount')
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:withdrawMoney', society, amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
if data.current.value == 'deposit_money' then
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'deposit_money_amount_' .. society,
|
||||
{
|
||||
title = _U('deposit_amount')
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:depositMoney', society, amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
if data.current.value == 'wash_money' then
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'wash_money_amount_' .. society,
|
||||
{
|
||||
title = _U('wash_money_amount')
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
local amount = tonumber(data.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu.close()
|
||||
TriggerServerEvent('esx_society:washMoney', society, amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
if data.current.value == 'manage_employees' then
|
||||
OpenManageEmployeesMenu(society)
|
||||
end
|
||||
|
||||
if data.current.value == 'manage_grades' then
|
||||
OpenManageGradesMenu(society)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
|
||||
if close then
|
||||
close(data, menu)
|
||||
end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function OpenManageEmployeesMenu(society)
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'manage_employees_' .. society,
|
||||
{
|
||||
title = _U('employee_management'),
|
||||
elements = {
|
||||
{label = _U('employee_list'), value = 'employee_list'},
|
||||
{label = _U('recruit'), value = 'recruit'},
|
||||
}
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
if data.current.value == 'employee_list' then
|
||||
OpenEmployeeList(society)
|
||||
end
|
||||
|
||||
if data.current.value == 'recruit' then
|
||||
OpenRecruitMenu(society)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function OpenEmployeeList(society)
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:getEmployees', function(employees)
|
||||
|
||||
local elements = {
|
||||
head = {_U('employee'), _U('grade'), _U('actions')},
|
||||
rows = {}
|
||||
}
|
||||
|
||||
for i=1, #employees, 1 do
|
||||
|
||||
local gradeLabel = (employees[i].job.grade_label == '' and employees[i].job.label or employees[i].job.grade_label)
|
||||
|
||||
table.insert(elements.rows, {
|
||||
data = employees[i],
|
||||
cols = {
|
||||
employees[i].name,
|
||||
gradeLabel,
|
||||
'{{' .. _U('promote') .. '|promote}} {{' .. _U('fire') .. '|fire}}'
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'list', GetCurrentResourceName(), 'employee_list_' .. society,
|
||||
elements,
|
||||
function(data, menu)
|
||||
|
||||
local employee = data.data
|
||||
|
||||
if data.value == 'promote' then
|
||||
menu.close()
|
||||
OpenPromoteMenu(society, employee)
|
||||
end
|
||||
|
||||
if data.value == 'fire' then
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, 'unemployed', 0)
|
||||
|
||||
end
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
OpenManageEmployeesMenu(society)
|
||||
end
|
||||
)
|
||||
|
||||
end, society)
|
||||
|
||||
end
|
||||
|
||||
function OpenRecruitMenu(society)
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:getOnlinePlayers', function(players)
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #players, 1 do
|
||||
if players[i].job.name ~= society then
|
||||
table.insert(elements, {label = players[i].name, value = players[i].source, name = players[i].name, identifier = players[i].identifier})
|
||||
end
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'recruit_' .. society,
|
||||
{
|
||||
title = _U('recruiting'),
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'recruit_confirm_' .. society,
|
||||
{
|
||||
title = _U('do_you_want_to_recruit', data.current.name),
|
||||
elements = {
|
||||
{label = _U('yes'), value = 'no'},
|
||||
{label = _U('no'), value = 'yes'},
|
||||
}
|
||||
},
|
||||
function(data2, menu2)
|
||||
|
||||
menu2.close()
|
||||
|
||||
if data2.current.value == 'yes' then
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenRecruitMenu(society)
|
||||
end, data.current.identifier, society, 0)
|
||||
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function OpenPromoteMenu(society, employee)
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:getJob', function(job)
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #job.grades, 1 do
|
||||
local gradeLabel = (job.grades[i].label == '' and job.label or job.grades[i].label)
|
||||
table.insert(elements, {label = gradeLabel, value = job.grades[i].grade, selected = (employee.job.grade == job.grades[i].grade)})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'promote_employee_' .. society,
|
||||
{
|
||||
title = _U('promote_employee', employee.name),
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJob', function()
|
||||
OpenEmployeeList(society)
|
||||
end, employee.identifier, society, data.current.value)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
OpenEmployeeList(society)
|
||||
end
|
||||
)
|
||||
|
||||
end, society)
|
||||
|
||||
end
|
||||
|
||||
function OpenManageGradesMenu(society)
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:getJob', function(job)
|
||||
|
||||
local elements = {}
|
||||
|
||||
for i=1, #job.grades, 1 do
|
||||
local gradeLabel = (job.grades[i].label == '' and job.label or job.grades[i].label)
|
||||
table.insert(elements, {label = gradeLabel .. ' $' .. job.grades[i].salary, value = job.grades[i].grade})
|
||||
end
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'manage_grades_' .. society,
|
||||
{
|
||||
title = _U('salary_management'),
|
||||
elements = elements
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
'dialog', GetCurrentResourceName(), 'manage_grades_amount_' .. society,
|
||||
{
|
||||
title = _U('salary_amount')
|
||||
},
|
||||
function(data2, menu2)
|
||||
|
||||
local amount = tonumber(data2.value)
|
||||
|
||||
if amount == nil then
|
||||
ESX.ShowNotification(_U('invalid_amount'))
|
||||
else
|
||||
menu2.close()
|
||||
|
||||
ESX.TriggerServerCallback('esx_society:setJobSalary', function()
|
||||
OpenManageGradesMenu(society)
|
||||
end, society, data.current.value, amount)
|
||||
end
|
||||
|
||||
end,
|
||||
function(data2, menu2)
|
||||
menu2.close()
|
||||
end
|
||||
)
|
||||
|
||||
end,
|
||||
function(data, menu)
|
||||
menu.close()
|
||||
end
|
||||
)
|
||||
|
||||
end, society)
|
||||
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
|
||||
@@ -69,11 +443,15 @@ AddEventHandler('esx:setJob', function(job)
|
||||
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx_addonAccount:setMoney')
|
||||
AddEventHandler('esx_addonAccount:setMoney', function(name, money)
|
||||
RegisterNetEvent('esx_addonaccount:setMoney')
|
||||
AddEventHandler('esx_addonaccount:setMoney', function(society, money)
|
||||
|
||||
if PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' and 'society_' .. PlayerData.job.name == name then
|
||||
if PlayerData.job ~= nil and PlayerData.job.grade_name == 'boss' and 'society_' .. PlayerData.job.name == society then
|
||||
UpdateSocietyMoneyHUDElement(money)
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
AddEventHandler('esx_society:openBossMenu', function(society, close, options)
|
||||
OpenBossMenu(society, close, options)
|
||||
end)
|
||||
Reference in New Issue
Block a user