improvement(server): Changed method to retrieve ESX.Jobs; do not define grade if unemployed; use ESX import for server

This commit is contained in:
Linden
2021-06-26 05:30:57 +10:00
parent 26b1a6856b
commit e9885a22f2
3 changed files with 17 additions and 17 deletions
+3 -2
View File
@@ -1,7 +1,7 @@
fx_version 'adamant'
game 'gta5'
description 'https://github.com/thelindat/esx_multicharacter'
version '1.1.0'
version '1.1.1'
dependencies {
'es_extended',
@@ -13,8 +13,9 @@ dependencies {
shared_script 'config.lua'
server_scripts {
'@es_extended/imports.lua',
'@mysql-async/lib/MySQL.lua',
'server/main.lua',
'server/*.lua',
}
client_scripts {
+8
View File
@@ -0,0 +1,8 @@
GetJobs = function()
local jobs = {}
while next(jobs) == nil do
Citizen.Wait(250)
jobs = exports['es_extended']:getSharedObject().Jobs
end
return jobs
end
+6 -15
View File
@@ -1,5 +1,6 @@
ESX = exports['es_extended']:getSharedObject()
if ESX.GetConfig().Multichar == true then
if not ESX then
SetTimeout(3000, print('[^3WARNING^7] Unable to start Multicharacter - your version of ESX is not compatible '))
elseif ESX.GetConfig().Multichar == true then
local fetchCharacters = -1
local IdentifierTables = {}
@@ -27,12 +28,10 @@ if ESX.GetConfig().Multichar == true then
}, function(result)
local characters = {}
for i=1, #result, 1 do
local job, grade = result[1].job, tostring(result[1].job_grade)
local job, grade = result[1].job or 'unemployed', tostring(result[1].job_grade)
if ESX.Jobs[job] and ESX.Jobs[job].grades[grade] then
grade = ESX.Jobs[job].grades[grade].label
if job ~= 'unemployed' then grade = ESX.Jobs[job].grades[grade].label else grade = '' end
job = ESX.Jobs[job].label
else
job, grade = 'Unemployed', ''
end
local accounts = json.decode(result[i].accounts)
local id = tonumber(string.sub(result[i].identifier, #Config.Prefix+1, string.find(result[i].identifier, ':')-1))
@@ -81,11 +80,7 @@ if ESX.GetConfig().Multichar == true then
end
end)
end)
while next(ESX.Jobs) == nil do
Citizen.Wait(250)
ESX.Jobs = exports['es_extended']:getSharedObject().Jobs
end
if not next(ESX.Jobs) then ESX.Jobs = GetJobs() end
end)
RegisterServerEvent("esx_multicharacter:SetupCharacters")
@@ -139,9 +134,5 @@ if ESX.GetConfig().Multichar == true then
end, true)
elseif ESX.GetConfig().Multichar == false then
SetTimeout(1000, print('[^3WARNING^7] Multicharacter is disabled - please check your ESX configuration'))
SetTimeout(3000, print('[^3WARNING^7] Multicharacter is disabled - please check your ESX configuration'))
else
SetTimeout(1000, print('[^3WARNING^7] Unable to start Multicharacter - your version of ESX is not compatible '))
SetTimeout(3000, print('[^3WARNING^7] Unable to start Multicharacter - your version of ESX is not compatible '))
end