mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 00:01:20 +00:00
Changed to promise and deleted ESX.JobsLoaded
This commit is contained in:
@@ -87,11 +87,6 @@ else
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
AddEventHandler("esx:jobsLoaded", function()
|
||||
ESX.JobsLoaded = true
|
||||
end)
|
||||
end
|
||||
|
||||
if GetResourceState("ox_lib") == "missing" then
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
ESX.Players = {}
|
||||
ESX.Jobs = {}
|
||||
ESX.Items = {}
|
||||
ESX.JobsLoaded = false
|
||||
Core = {}
|
||||
Core.JobsPlayerCount = {}
|
||||
Core.UsableItemsCallbacks = {}
|
||||
@@ -11,6 +10,7 @@ Core.PickupId = 0
|
||||
Core.PlayerFunctionOverrides = {}
|
||||
Core.DatabaseConnected = false
|
||||
Core.playersByIdentifier = {}
|
||||
Core.JobsLoaded = promise:new()
|
||||
|
||||
---@type table<string, CVehicleData>
|
||||
Core.vehicles = {}
|
||||
|
||||
@@ -505,6 +505,10 @@ end
|
||||
|
||||
---@return nil
|
||||
function ESX.RefreshJobs()
|
||||
if Core.JobsLoaded.value then
|
||||
Core.JobsLoaded = promise:new()
|
||||
end
|
||||
|
||||
local Jobs = {}
|
||||
local jobs = MySQL.query.await("SELECT * FROM jobs")
|
||||
|
||||
@@ -538,6 +542,7 @@ function ESX.RefreshJobs()
|
||||
end
|
||||
|
||||
TriggerEvent("esx:jobsLoaded")
|
||||
Core.JobsLoaded:resolve(true)
|
||||
end
|
||||
|
||||
---@param item string
|
||||
@@ -597,6 +602,11 @@ end
|
||||
|
||||
---@return table
|
||||
function ESX.GetJobs()
|
||||
while not Core.JobsLoaded.value do
|
||||
print("Waiting for ESX Jobs to Load")
|
||||
Citizen.Wait(200)
|
||||
end
|
||||
|
||||
return ESX.Jobs
|
||||
end
|
||||
|
||||
@@ -763,6 +773,11 @@ end
|
||||
---@param grade string
|
||||
---@return boolean
|
||||
function ESX.DoesJobExist(job, grade)
|
||||
while not Core.JobsLoaded.value do
|
||||
print("Waiting for ESX Jobs to Load")
|
||||
Citizen.Wait(200)
|
||||
end
|
||||
|
||||
return (ESX.Jobs[job] and ESX.Jobs[job].grades[tostring(grade)] ~= nil) or false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user