chore(coding-style): correct indentation

This commit is contained in:
Romain Lanz
2017-09-14 21:21:24 +02:00
parent de6e240e33
commit 2fa1ff9ff4
7 changed files with 638 additions and 646 deletions
+15 -15
View File
@@ -3,22 +3,22 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Society' description 'ESX Society'
server_scripts { server_scripts {
'@mysql-async/lib/MySQL.lua', '@mysql-async/lib/MySQL.lua',
'@es_extended/locale.lua', '@es_extended/locale.lua',
'locales/de.lua', 'locales/de.lua',
'locales/br.lua', 'locales/br.lua',
'locales/en.lua', 'locales/en.lua',
'locales/fr.lua', 'locales/fr.lua',
'config.lua', 'config.lua',
'server/main.lua' 'server/main.lua'
} }
client_scripts { client_scripts {
'@es_extended/locale.lua', '@es_extended/locale.lua',
'locales/de.lua', 'locales/de.lua',
'locales/br.lua', 'locales/br.lua',
'locales/en.lua', 'locales/en.lua',
'locales/fr.lua', 'locales/fr.lua',
'config.lua', 'config.lua',
'client/main.lua' 'client/main.lua'
} }
+308 -308
View File
File diff suppressed because one or more lines are too long
+26 -28
View File
@@ -1,30 +1,28 @@
Locales['br'] = { Locales['br'] = {
['actions'] = 'actions',
['actions'] = 'actions', ['deposit_amount'] = 'deposit amount',
['deposit_amount'] = 'deposit amount', ['deposit_society_money'] = 'deposit society money',
['deposit_society_money'] = 'deposit society money', ['employee'] = 'employee',
['employee'] = 'employee', ['employee_list'] = 'employee list',
['employee_list'] = 'employee list', ['employee_management'] = 'employee management',
['employee_management'] = 'employee management', ['fire'] = 'fire',
['fire'] = 'fire', ['grade'] = 'grade',
['grade'] = 'grade', ['have_deposited'] = 'Você depositou ~r~$',
['have_deposited'] = 'Você depositou ~r~$', ['have_withdrawn'] = 'Você sacou ~g~$',
['have_withdrawn'] = 'Você sacou ~g~$', ['invalid_amount'] = 'invalid amount',
['invalid_amount'] = 'invalid amount', ['invalid_amount'] = 'Quantidade inválida',
['invalid_amount'] = 'Quantidade inválida', ['no'] = 'no',
['no'] = 'no', ['promote'] = 'promote',
['promote'] = 'promote', ['promote_employee'] = 'promote %s',
['promote_employee'] = 'promote %s', ['recruit'] = 'recruit',
['recruit'] = 'recruit', ['recruiting'] = 'recruiting',
['recruiting'] = 'recruiting', ['salary_amount'] = 'salary amount',
['salary_amount'] = 'salary amount', ['salary_management'] = 'salary management',
['salary_management'] = 'salary management', ['wash_money'] = 'wash money',
['wash_money'] = 'wash money', ['wash_money_amount'] = 'amount to wash',
['wash_money_amount'] = 'amount to wash', ['withdraw_amount'] = 'witdraw amount',
['withdraw_amount'] = 'witdraw amount', ['withdraw_society_money'] = 'withdraw society money',
['withdraw_society_money'] = 'withdraw society money', ['yes'] = 'yes',
['yes'] = 'yes', ['you_have'] = 'Você tem ~g~$',
['you_have'] = 'Você tem ~g~$', ['you_have_laundered'] = 'Você ~r~lavou~s~ seu dinheiro: ~g~$',
['you_have_laundered'] = 'Você ~r~lavou~s~ seu dinheiro: ~g~$',
} }
+5 -7
View File
@@ -1,9 +1,7 @@
Locales['de'] = { Locales['de'] = {
['have_withdrawn'] = 'abgehoben ~g~$',
['have_withdrawn'] = 'abgehoben ~g~$', ['invalid_amount'] = 'ungültiger Betrag',
['invalid_amount'] = 'ungültiger Betrag', ['have_deposited'] = 'eingezahlt ~r~$',
['have_deposited'] = 'eingezahlt ~r~$', ['you_have'] = 'du hast ~g~$',
['you_have'] = 'du hast ~g~$', ['you_have_laundered'] = 'du hast dein Geld ~r~gewaschen~s~: ~g~$',
['you_have_laundered'] = 'du hast dein Geld ~r~gewaschen~s~: ~g~$',
} }
+33 -35
View File
@@ -1,37 +1,35 @@
Locales['en'] = { Locales['en'] = {
['actions'] = 'actions',
['actions'] = 'actions', ['deposit_amount'] = 'deposit amount',
['deposit_amount'] = 'deposit amount', ['deposit_society_money'] = 'deposit society money',
['deposit_society_money'] = 'deposit society money', ['do_you_want_to_recruit'] = 'do you want to recruit %s?',
['do_you_want_to_recruit'] = 'do you want to recruit %s?', ['employee'] = 'employee',
['employee'] = 'employee', ['employee_list'] = 'employee list',
['employee_list'] = 'employee list', ['employee_management'] = 'employee management',
['employee_management'] = 'employee management', ['fire'] = 'fire',
['fire'] = 'fire', ['grade'] = 'grade',
['grade'] = 'grade', ['have_deposited'] = 'you have deposited ~r~$',
['have_deposited'] = 'you have deposited ~r~$', ['have_withdrawn'] = 'you have withdrawn ~g~$',
['have_withdrawn'] = 'you have withdrawn ~g~$', ['invalid_amount'] = 'invalid amount',
['invalid_amount'] = 'invalid amount', ['invalid_amount'] = 'invalid amount',
['invalid_amount'] = 'invalid amount', ['no'] = 'no',
['no'] = 'no', ['promote'] = 'promote',
['promote'] = 'promote', ['promote_employee'] = 'promote %s',
['promote_employee'] = 'promote %s', ['recruit'] = 'recruit',
['recruit'] = 'recruit', ['recruiting'] = 'recruiting',
['recruiting'] = 'recruiting', ['salary_amount'] = 'salary amount',
['salary_amount'] = 'salary amount', ['salary_management'] = 'salary management',
['salary_management'] = 'salary management', ['wash_money'] = 'wash money',
['wash_money'] = 'wash money', ['wash_money_amount'] = 'amount to wash',
['wash_money_amount'] = 'amount to wash', ['withdraw_amount'] = 'witdraw amount',
['withdraw_amount'] = 'witdraw amount', ['withdraw_society_money'] = 'withdraw society money',
['withdraw_society_money'] = 'withdraw society money', ['yes'] = 'yes',
['yes'] = 'yes', ['you_have'] = 'you have ~g~$',
['you_have'] = 'you have ~g~$', ['you_have_laundered'] = 'you have ~r~laundered~s~ your money: ~g~$',
['you_have_laundered'] = 'you have ~r~laundered~s~ your money: ~g~$', ['you_have_hired'] = 'you have recruited %s',
['you_have_hired'] = 'you have recruited %s', ['you_have_been_hired'] = 'you have been hired by %s',
['you_have_been_hired'] = 'you have been hired by %s', ['you_have_fired'] = 'you have fired %s',
['you_have_fired'] = 'you have fired %s', ['you_have_been_fired'] = 'you have been fired from %s',
['you_have_been_fired'] = 'you have been fired from %s', ['you_have_promoted'] = 'you have promoted %s as %s',
['you_have_promoted'] = 'you have promoted %s as %s', ['you_have_been_promoted'] = 'you have been promoted',
['you_have_been_promoted'] = 'you have been promoted',
} }
+28 -30
View File
@@ -1,37 +1,35 @@
Locales['fr'] = { Locales['fr'] = {
['actions'] = 'actions',
['actions'] = 'actions', ['deposit_amount'] = 'montant du dépôt',
['deposit_amount'] = 'montant du dépôt', ['deposit_society_money'] = 'déposer argent société',
['deposit_society_money'] = 'déposer argent société', ['do_you_want_to_recruit'] = 'Voulez-vous recruter %s ?',
['do_you_want_to_recruit'] = 'Voulez-vous recruter %s ?', ['employee'] = 'employé',
['employee'] = 'employé', ['employee_list'] = 'liste des employés',
['employee_list'] = 'liste des employés', ['employee_management'] = 'gestion employés',
['employee_management'] = 'gestion employés', ['fire'] = 'licencier',
['fire'] = 'licencier', ['grade'] = 'grade',
['grade'] = 'grade', ['have_deposited'] = 'vous avez déposé ~r~$',
['have_deposited'] = 'vous avez déposé ~r~$', ['have_withdrawn'] = 'vous avez retiré ~g~$',
['have_withdrawn'] = 'vous avez retiré ~g~$', ['invalid_amount'] = 'montant invalide',
['invalid_amount'] = 'montant invalide', ['invalid_amount'] = 'montant invalide',
['invalid_amount'] = 'montant invalide', ['no'] = 'non',
['no'] = 'non', ['promote'] = 'promouvoir',
['promote'] = 'promouvoir', ['promote_employee'] = 'promouvoir %s',
['promote_employee'] = 'promouvoir %s', ['recruit'] = 'recruter',
['recruit'] = 'recruter', ['recruiting'] = 'recrutement',
['recruiting'] = 'recrutement', ['salary_amount'] = 'montant du salaire',
['salary_amount'] = 'montant du salaire', ['salary_management'] = 'gestion salaires',
['salary_management'] = 'gestion salaires', ['wash_money'] = 'blanchir argent',
['wash_money'] = 'blanchir argent', ['wash_money_amount'] = 'montant à blanchir',
['wash_money_amount'] = 'montant à blanchir', ['withdraw_amount'] = 'montant du retrait',
['withdraw_amount'] = 'montant du retrait', ['withdraw_society_money'] = 'retirer argent société',
['withdraw_society_money'] = 'retirer argent société', ['yes'] = 'oui',
['yes'] = 'oui', ['you_have'] = 'vous avez ~g~$',
['you_have'] = 'vous avez ~g~$', ['you_have_laundered'] = 'vous avez ~r~blanchi~s~ votre argent : ~g~$',
['you_have_laundered'] = 'vous avez ~r~blanchi~s~ votre argent : ~g~$', ['you_have_hired'] = 'Vous avez recruté %s',
['you_have_hired'] = 'Vous avez recruté %s',
['you_have_been_hired'] = 'Vous avez été recruté dans la société %s', ['you_have_been_hired'] = 'Vous avez été recruté dans la société %s',
['you_have_fired'] = 'Vous avez viré %s', ['you_have_fired'] = 'Vous avez viré %s',
['you_have_been_fired'] = 'Vous avez été viré de la société %s', ['you_have_been_fired'] = 'Vous avez été viré de la société %s',
['you_have_promoted'] = 'Vous avez promu %s en tant que %s', ['you_have_promoted'] = 'Vous avez promu %s en tant que %s',
['you_have_been_promoted'] = 'Vous avez été promu', ['you_have_been_promoted'] = 'Vous avez été promu',
} }
+223 -223
View File
@@ -17,377 +17,377 @@ function stringsplit(inputstr, sep)
end end
function GetSociety(name) function GetSociety(name)
for i=1, #RegisteredSocieties, 1 do for i=1, #RegisteredSocieties, 1 do
if RegisteredSocieties[i].name == name then if RegisteredSocieties[i].name == name then
return RegisteredSocieties[i] return RegisteredSocieties[i]
end end
end end
end end
AddEventHandler('onMySQLReady', function() AddEventHandler('onMySQLReady', function()
local result = MySQL.Sync.fetchAll('SELECT * FROM jobs', {}) local result = MySQL.Sync.fetchAll('SELECT * FROM jobs', {})
for i=1, #result, 1 do for i=1, #result, 1 do
Jobs[result[i].name] = result[i] Jobs[result[i].name] = result[i]
Jobs[result[i].name].grades = {} Jobs[result[i].name].grades = {}
end end
local result2 = MySQL.Sync.fetchAll('SELECT * FROM job_grades', {}) local result2 = MySQL.Sync.fetchAll('SELECT * FROM job_grades', {})
for i=1, #result2, 1 do for i=1, #result2, 1 do
Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i] Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i]
end end
end) end)
AddEventHandler('esx_society:registerSociety', function(name, label, account, datastore, inventory, data) AddEventHandler('esx_society:registerSociety', function(name, label, account, datastore, inventory, data)
local found = false local found = false
local society = { local society = {
name = name, name = name,
label = label, label = label,
account = account, account = account,
datastore = datastore, datastore = datastore,
inventory = inventory, inventory = inventory,
data = data, data = data,
} }
for i=1, #RegisteredSocieties, 1 do for i=1, #RegisteredSocieties, 1 do
if RegisteredSocieties[i].name == name then if RegisteredSocieties[i].name == name then
found = true found = true
RegisteredSocieties[i] = society RegisteredSocieties[i] = society
break break
end end
end end
if not found then if not found then
table.insert(RegisteredSocieties, society) table.insert(RegisteredSocieties, society)
end end
end) end)
AddEventHandler('esx_society:getSocieties', function(cb) AddEventHandler('esx_society:getSocieties', function(cb)
cb(RegisteredSocieties) cb(RegisteredSocieties)
end) end)
AddEventHandler('esx_society:getSociety', function(name, cb) AddEventHandler('esx_society:getSociety', function(name, cb)
cb(GetSociety(name)) cb(GetSociety(name))
end) end)
RegisterServerEvent('esx_society:withdrawMoney') RegisterServerEvent('esx_society:withdrawMoney')
AddEventHandler('esx_society:withdrawMoney', function(society, amount) AddEventHandler('esx_society:withdrawMoney', function(society, amount)
local xPlayer = ESX.GetPlayerFromId(source) local xPlayer = ESX.GetPlayerFromId(source)
local society = GetSociety(society) local society = GetSociety(society)
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
if amount > 0 and account.money >= amount then if amount > 0 and account.money >= amount then
account.removeMoney(amount) account.removeMoney(amount)
xPlayer.addMoney(amount) xPlayer.addMoney(amount)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. amount) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. amount)
else else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount')) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
end end
end) end)
end) end)
RegisterServerEvent('esx_society:depositMoney') RegisterServerEvent('esx_society:depositMoney')
AddEventHandler('esx_society:depositMoney', function(society, amount) AddEventHandler('esx_society:depositMoney', function(society, amount)
local xPlayer = ESX.GetPlayerFromId(source) local xPlayer = ESX.GetPlayerFromId(source)
local society = GetSociety(society) local society = GetSociety(society)
if amount > 0 and xPlayer.get('money') >= amount then if amount > 0 and xPlayer.get('money') >= amount then
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
xPlayer.removeMoney(amount) xPlayer.removeMoney(amount)
account.addMoney(amount) account.addMoney(amount)
end) end)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_deposited') .. amount) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_deposited') .. amount)
else else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount')) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
end end
end) end)
RegisterServerEvent('esx_society:washMoney') RegisterServerEvent('esx_society:washMoney')
AddEventHandler('esx_society:washMoney', function(society, amount) AddEventHandler('esx_society:washMoney', function(society, amount)
local xPlayer = ESX.GetPlayerFromId(source) local xPlayer = ESX.GetPlayerFromId(source)
local account = xPlayer.getAccount('black_money') local account = xPlayer.getAccount('black_money')
if amount > 0 and account.money >= amount then if amount > 0 and account.money >= amount then
xPlayer.removeAccountMoney('black_money', amount) xPlayer.removeAccountMoney('black_money', amount)
MySQL.Async.execute( MySQL.Async.execute(
'INSERT INTO society_moneywash (identifier, society, amount) VALUES (@identifier, @society, @amount)', 'INSERT INTO society_moneywash (identifier, society, amount) VALUES (@identifier, @society, @amount)',
{ {
['@identifier'] = xPlayer.identifier, ['@identifier'] = xPlayer.identifier,
['@society'] = society, ['@society'] = society,
['@amount'] = amount ['@amount'] = amount
}, },
function(rowsChanged) function(rowsChanged)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have') .. amount .. '~s~ en attente de ~r~blanchiement~s~ (24h)') TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have') .. amount .. '~s~ en attente de ~r~blanchiement~s~ (24h)')
end end
) )
else else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount')) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
end end
end) end)
RegisterServerEvent('esx_society:putVehicleInGarage') RegisterServerEvent('esx_society:putVehicleInGarage')
AddEventHandler('esx_society:putVehicleInGarage', function(societyName, vehicle) AddEventHandler('esx_society:putVehicleInGarage', function(societyName, vehicle)
local society = GetSociety(societyName) local society = GetSociety(societyName)
TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store)
local garage = store.get('garage') or {} local garage = store.get('garage') or {}
table.insert(garage, vehicle) table.insert(garage, vehicle)
store.set('garage', garage) store.set('garage', garage)
end) end)
end) end)
RegisterServerEvent('esx_society:removeVehicleFromGarage') RegisterServerEvent('esx_society:removeVehicleFromGarage')
AddEventHandler('esx_society:removeVehicleFromGarage', function(societyName, vehicle) AddEventHandler('esx_society:removeVehicleFromGarage', function(societyName, vehicle)
local society = GetSociety(societyName) local society = GetSociety(societyName)
TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store)
local garage = store.get('garage') or {} local garage = store.get('garage') or {}
for i=1, #garage, 1 do for i=1, #garage, 1 do
if garage[i].plate == vehicle.plate then if garage[i].plate == vehicle.plate then
table.remove(garage, i) table.remove(garage, i)
break break
end end
end end
store.set('garage', garage) store.set('garage', garage)
end) end)
end) end)
ESX.RegisterServerCallback('esx_society:getSocietyMoney', function(source, cb, societyName) ESX.RegisterServerCallback('esx_society:getSocietyMoney', function(source, cb, societyName)
local society = GetSociety(societyName) local society = GetSociety(societyName)
if society ~= nil then if society ~= nil then
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
cb(account.money) cb(account.money)
end) end)
else else
cb(0) cb(0)
end end
end) end)
ESX.RegisterServerCallback('esx_society:getEmployees', function(source, cb, society) ESX.RegisterServerCallback('esx_society:getEmployees', function(source, cb, society)
MySQL.Async.fetchAll( MySQL.Async.fetchAll(
'SELECT * FROM users WHERE job = @job ORDER BY job_grade DESC', 'SELECT * FROM users WHERE job = @job ORDER BY job_grade DESC',
{ {
['@job'] = society ['@job'] = society
}, },
function(result) function(result)
local employees = {} local employees = {}
for i=1, #result, 1 do for i=1, #result, 1 do
table.insert(employees, { table.insert(employees, {
name = result[i].name, name = result[i].name,
identifier = result[i].identifier, identifier = result[i].identifier,
job = { job = {
name = result[i].job, name = result[i].job,
label = Jobs[result[i].job].label, label = Jobs[result[i].job].label,
grade = result[i].job_grade, grade = result[i].job_grade,
grade_name = Jobs[result[i].job].grades[tostring(result[i].job_grade)].name, grade_name = Jobs[result[i].job].grades[tostring(result[i].job_grade)].name,
grade_label = Jobs[result[i].job].grades[tostring(result[i].job_grade)].label, grade_label = Jobs[result[i].job].grades[tostring(result[i].job_grade)].label,
} }
}) })
end end
cb(employees) cb(employees)
end end
) )
end) end)
ESX.RegisterServerCallback('esx_society:getJob', function(source, cb, society) ESX.RegisterServerCallback('esx_society:getJob', function(source, cb, society)
local job = json.decode(json.encode(Jobs[society])) local job = json.decode(json.encode(Jobs[society]))
local grades = {} local grades = {}
for k,v in pairs(job.grades) do for k,v in pairs(job.grades) do
table.insert(grades, v) table.insert(grades, v)
end end
table.sort(grades, function(a, b) table.sort(grades, function(a, b)
return a.grade < b.grade return a.grade < b.grade
end) end)
job.grades = grades job.grades = grades
cb(job) cb(job)
end) end)
ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier, job, grade, type) ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier, job, grade, type)
local xPlayer = ESX.GetPlayerFromIdentifier(identifier) local xPlayer = ESX.GetPlayerFromIdentifier(identifier)
if type == 'hire' then if type == 'hire' then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_hired', job)) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_hired', job))
elseif type == 'promote' then elseif type == 'promote' then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_promoted')) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_promoted'))
elseif type == 'fire' then elseif type == 'fire' then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_fired', xPlayer.getJob().label)) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_been_fired', xPlayer.getJob().label))
end end
if xPlayer ~= nil then if xPlayer ~= nil then
xPlayer.setJob(job, grade) xPlayer.setJob(job, grade)
end end
MySQL.Async.execute( MySQL.Async.execute(
'UPDATE users SET job = @job, job_grade = @job_grade WHERE identifier = @identifier', 'UPDATE users SET job = @job, job_grade = @job_grade WHERE identifier = @identifier',
{ {
['@job'] = job, ['@job'] = job,
['@job_grade'] = grade, ['@job_grade'] = grade,
['@identifier'] = identifier ['@identifier'] = identifier
}, },
function(rowsChanged) function(rowsChanged)
cb() cb()
end end
) )
end) end)
ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, grade, salary) ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, grade, salary)
MySQL.Async.execute( MySQL.Async.execute(
'UPDATE job_grades SET salary = @salary WHERE job_name = @job_name AND grade = @grade', 'UPDATE job_grades SET salary = @salary WHERE job_name = @job_name AND grade = @grade',
{ {
['@salary'] = salary, ['@salary'] = salary,
['@job_name'] = job, ['@job_name'] = job,
['@grade'] = grade ['@grade'] = grade
}, },
function(rowsChanged) function(rowsChanged)
Jobs[job].grades[tostring(grade)].salary = salary Jobs[job].grades[tostring(grade)].salary = salary
local xPlayers = ESX.GetPlayers() local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.name == job and xPlayer.job.grade == grade then if xPlayer.job.name == job and xPlayer.job.grade == grade then
xPlayer.setJob(job, grade) xPlayer.setJob(job, grade)
end end
end end
cb() cb()
end end
) )
end) end)
ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb) ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb)
local xPlayers = ESX.GetPlayers() local xPlayers = ESX.GetPlayers()
local players = {} local players = {}
for i=1, #xPlayers, 1 do for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
table.insert(players, { table.insert(players, {
source = xPlayer.source, source = xPlayer.source,
identifier = xPlayer.identifier, identifier = xPlayer.identifier,
name = xPlayer.name, name = xPlayer.name,
job = xPlayer.job job = xPlayer.job
}) })
end end
cb(players) cb(players)
end) end)
ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, cb, societyName) ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, cb, societyName)
local society = GetSociety(societyName) local society = GetSociety(societyName)
TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store)
local garage = store.get('garage') or {} local garage = store.get('garage') or {}
cb(garage) cb(garage)
end) end)
end) end)
function WashMoneyCRON(d, h, m) function WashMoneyCRON(d, h, m)
MySQL.Async.fetchAll( MySQL.Async.fetchAll(
'SELECT * FROM society_moneywash', 'SELECT * FROM society_moneywash',
{}, {},
function(result) function(result)
local xPlayers = ESX.GetPlayers() local xPlayers = ESX.GetPlayers()
for i=1, #result, 1 do for i=1, #result, 1 do
local foundPlayer = false local foundPlayer = false
local xPlayer = nil local xPlayer = nil
local society = GetSociety(result[i].society) local society = GetSociety(result[i].society)
for j=1, #xPlayers, 1 do for j=1, #xPlayers, 1 do
local xPlayer2 = ESX.GetPlayerFromId(xPlayers[j]) local xPlayer2 = ESX.GetPlayerFromId(xPlayers[j])
if xPlayer2.identifier == result[i].identifier then if xPlayer2.identifier == result[i].identifier then
foundPlayer = true foundPlayer = true
xPlayer = xPlayer2 xPlayer = xPlayer2
end end
end end
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
account.addMoney(result[i].amount) account.addMoney(result[i].amount)
end) end)
if foundPlayer then if foundPlayer then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_laundered') .. result[i].amount) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_laundered') .. result[i].amount)
end end
MySQL.Async.execute( MySQL.Async.execute(
'DELETE FROM society_moneywash WHERE id = @id', 'DELETE FROM society_moneywash WHERE id = @id',
{ {
['@id'] = result[i].id ['@id'] = result[i].id
} }
) )
end end
end end
) )
end end