From f687c849ca6eab58fdc6ad1bc4e9c5fab250eaad Mon Sep 17 00:00:00 2001 From: Benzo <102178921+Benzo00@users.noreply.github.com> Date: Mon, 13 Jun 2022 04:01:42 +0200 Subject: [PATCH] society update --- [esx_addons]/esx_society/server/main.lua | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/[esx_addons]/esx_society/server/main.lua b/[esx_addons]/esx_society/server/main.lua index 8e5415a0..e038eeed 100644 --- a/[esx_addons]/esx_society/server/main.lua +++ b/[esx_addons]/esx_society/server/main.lua @@ -287,7 +287,8 @@ ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, MySQL.update('UPDATE job_grades SET salary = ? WHERE job_name = ? AND grade = ?', {salary, job, grade}, function(rowsChanged) Jobs[job].grades[tostring(grade)].salary = salary - + ESX.RefreshJobs() + Wait(1) local xPlayers = ESX.GetExtendedPlayers('job', job) for _, xTarget in pairs(xPlayers) do @@ -295,7 +296,6 @@ ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, xTarget.setJob(job, grade) end end - cb() end) else @@ -308,6 +308,31 @@ ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, end end) + +ESX.RegisterServerCallback('esx_society:setJobLabel', function(source, cb, job, grade, label) + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then + MySQL.update('UPDATE job_grades SET label = ? WHERE job_name = ? AND grade = ?', {label, job, grade}, + function(rowsChanged) + Jobs[job].grades[tostring(grade)].label = label + ESX.RefreshJobs() + Wait(1) + local xPlayers = ESX.GetExtendedPlayers('job', job) + for _, xTarget in pairs(xPlayers) do + + if xTarget.job.grade == grade then + xTarget.setJob(job, grade) + end + end + cb() + end) + else + print(('esx_society: %s attempted to setJobSalary'):format(xPlayer.identifier)) + cb() + end +end) + local getOnlinePlayers, onlinePlayers = false, {} ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb) if getOnlinePlayers == false and next(onlinePlayers) == nil then -- Prevent multiple xPlayer loops from running in quick succession