Skip to content

Commit

Permalink
Merge pull request #525 from bitpredator/develop
Browse files Browse the repository at this point in the history
refactor: esx_society\client+server\main.lua fix lint error
  • Loading branch information
bitpredator authored Sep 20, 2023
2 parents 37f54cc + 367f134 commit 68302df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions server-data/resources/[esx]/esx_society/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function UpdateSocietyMoneyHUDElement(money)
TriggerEvent('esx_society:setSocietyMoney', money)
end

function OpenBossMenu(society, close, options)
function OpenBossMenu(society, _, options)
options = options or {}
local elements = {
{unselectable = true, icon = "fas fa-user", title = _U('boss_menu')}
Expand Down Expand Up @@ -165,11 +165,11 @@ function OpenManageEmployeesMenu(society, options)

elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}

ESX.OpenContext("right", elements, function(_,element)
ESX.OpenContext("right", elements, function(_, element)
if element.value == "employee_list" then
OpenEmployeeList(society, options)
elseif element.value == "recruit" then
OpenRecruitMenu(society, options)
OpenRecruitMenu(society, options)
elseif element.value == "return" then
OpenBossMenu(society, nil, options)
end
Expand All @@ -190,7 +190,7 @@ function OpenEmployeeList(society, options)

elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}

ESX.OpenContext("right", elements, function(menu,element)
ESX.OpenContext("right", elements, function(_,element)
if element.value == "return" then
OpenManageEmployeesMenu(society, options)
else
Expand All @@ -200,7 +200,7 @@ function OpenEmployeeList(society, options)
{icon = "fas fa-user", title = "Fire", value = "fire"},
{icon = "fas fa-arrow-left", title = "Return", value = "return"}
}
ESX.OpenContext("right", elements2, function(menu2,element2)
ESX.OpenContext("right", elements2, function(_,element2)
local employee = element.data
if element2.value == "promote" then
ESX.CloseContext()
Expand Down Expand Up @@ -271,7 +271,7 @@ function OpenPromoteMenu(society, employee, options)

elements[#elements+1] = {icon = "fas fa-arrow-left", title = "Return", value = "return"}

ESX.OpenContext("right", elements, function(menu,element)
ESX.OpenContext("right", elements, function(_, element)
if element.value == "return" then
OpenEmployeeList(society, options)
else
Expand All @@ -281,7 +281,7 @@ function OpenPromoteMenu(society, employee, options)
OpenEmployeeList(society, options)
end, employee.identifier, society, element.value, 'promote')
end
end, function(menu)
end, function()
OpenEmployeeList(society, options)
end)
end, society)
Expand Down
24 changes: 12 additions & 12 deletions server-data/resources/[esx]/esx_society/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ AddEventHandler('esx_society:washMoney', function(society, amount)
xPlayer.removeAccountMoney('black_money', amount, "Washing")

MySQL.insert('INSERT INTO society_moneywash (identifier, society, amount) VALUES (?, ?, ?)', {xPlayer.identifier, society, amount},
function(rowsChanged)
function()
xPlayer.showNotification(_U('you_have', ESX.Math.GroupDigits(amount)))
end)
else
Expand Down Expand Up @@ -205,7 +205,7 @@ ESX.RegisterServerCallback('esx_society:getEmployees', function(_, cb, society)
local employees = {}

local xPlayers = ESX.GetExtendedPlayers('job', society)
for i=1, #(xPlayers) do
for i=1, #(xPlayers) do
local xPlayer = xPlayers[i]

local name = xPlayer.name
Expand Down Expand Up @@ -234,11 +234,11 @@ ESX.RegisterServerCallback('esx_society:getEmployees', function(_, cb, society)

MySQL.query(query, {society},
function(result)
for k, row in pairs(result) do
for _, row in pairs(result) do
local alreadyInTable
local identifier = row.identifier

for k, v in pairs(employees) do
for _, v in pairs(employees) do
if v.identifier == identifier then
alreadyInTable = true
end
Expand Down Expand Up @@ -270,11 +270,11 @@ ESX.RegisterServerCallback('esx_society:getEmployees', function(_, cb, society)

end)

ESX.RegisterServerCallback('esx_society:getJob', function(source, cb, society)
ESX.RegisterServerCallback('esx_society:getJob', function(_, cb, society)
local job = json.decode(json.encode(Jobs[society]))
local grades = {}

for k,v in pairs(job.grades) do
for _,v in pairs(job.grades) do
table.insert(grades, v)
end

Expand Down Expand Up @@ -311,7 +311,7 @@ ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier
cb()
else
MySQL.update('UPDATE users SET job = ?, job_grade = ? WHERE identifier = ?', {job, grade, identifier},
function(rowsChanged)
function()
cb()
end)
end
Expand All @@ -328,7 +328,7 @@ ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job,
if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then
if salary <= Config.MaxSalary then
MySQL.update('UPDATE job_grades SET salary = ? WHERE job_name = ? AND grade = ?', {salary, job, grade},
function(rowsChanged)
function()
Jobs[job].grades[tostring(grade)].salary = salary
ESX.RefreshJobs()
Wait(1)
Expand Down Expand Up @@ -356,7 +356,7 @@ ESX.RegisterServerCallback('esx_society:setJobLabel', function(source, cb, job,

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)
function()
Jobs[job].grades[tostring(grade)].label = label
ESX.RefreshJobs()
Wait(1)
Expand All @@ -376,12 +376,12 @@ ESX.RegisterServerCallback('esx_society:setJobLabel', function(source, cb, job,
end)

local getOnlinePlayers, onlinePlayers = false, {}
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(_, cb)
if getOnlinePlayers == false and next(onlinePlayers) == nil then -- Prevent multiple xPlayer loops from running in quick succession
getOnlinePlayers, onlinePlayers = true, {}

local xPlayers = ESX.GetExtendedPlayers()
for i=1, #(xPlayers) do
for i=1, #(xPlayers) do
local xPlayer = xPlayers[i]
table.insert(onlinePlayers, {
source = xPlayer.source,
Expand All @@ -400,7 +400,7 @@ ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
cb(onlinePlayers)
end)

ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, cb, societyName)
ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(_, cb, societyName)
local society = GetSociety(societyName)
if not society then
print(('[^3WARNING^7] Attempting To get a non-existing society - %s!'):format(societyName))
Expand Down

0 comments on commit 68302df

Please sign in to comment.