mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
refactor(esx_society): allow registering society with exports
This commit is contained in:
@@ -9,24 +9,24 @@ function GetSociety(name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resourceName)
|
exports("GetSociety", GetSociety)
|
||||||
if resourceName == GetCurrentResourceName() then
|
|
||||||
local result = MySQL.query.await('SELECT * FROM jobs')
|
|
||||||
|
|
||||||
for i = 1, #result, 1 do
|
CreateThread(function()
|
||||||
Jobs[result[i].name] = result[i]
|
local result = MySQL.query.await('SELECT * FROM jobs')
|
||||||
Jobs[result[i].name].grades = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
local result2 = MySQL.query.await('SELECT * FROM job_grades')
|
for i = 1, #result, 1 do
|
||||||
|
Jobs[result[i].name] = result[i]
|
||||||
|
Jobs[result[i].name].grades = {}
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, #result2, 1 do
|
local result2 = MySQL.query.await('SELECT * FROM job_grades')
|
||||||
Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i]
|
|
||||||
end
|
for i = 1, #result2, 1 do
|
||||||
|
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)
|
function registerSociety(name, label, account, datastore, inventory, data)
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
local society = {
|
local society = {
|
||||||
@@ -46,9 +46,13 @@ AddEventHandler('esx_society:registerSociety', function(name, label, account, da
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not found then
|
if not found then
|
||||||
table.insert(RegisteredSocieties, society)
|
RegisteredSocieties[#RegisteredSocieties + 1] = society
|
||||||
|
print(("[^2INFO^7] Registered Society ^5%s^7"):format(label))
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
AddEventHandler('esx_society:registerSociety',registerSociety)
|
||||||
|
exports("registerSociety", registerSociety)
|
||||||
|
|
||||||
AddEventHandler('esx_society:getSocieties', function(cb)
|
AddEventHandler('esx_society:getSocieties', function(cb)
|
||||||
cb(RegisteredSocieties)
|
cb(RegisteredSocieties)
|
||||||
|
|||||||
Reference in New Issue
Block a user