Added ESX.JobsLoaded and esx:jobsLoaded

This commit is contained in:
Kr3mu
2025-07-28 16:42:15 +02:00
parent 4fbdb16de2
commit ef74169620
3 changed files with 16 additions and 8 deletions
+10 -5
View File
@@ -1,9 +1,9 @@
ESX = exports["es_extended"]:getSharedObject()
ESX.currentResourceName = GetCurrentResourceName()
OnPlayerData = function (key, val, last) end
OnPlayerData = function(key, val, last) end
local function TrackPedCoordsOnce()
local function TrackPedCoordsOnce()
if not ESX or not ESX.PlayerData then
return
end
@@ -48,8 +48,8 @@ if not IsDuplicityVersion() then -- Only register this event for the client
ESX.PlayerData = {}
end)
local external = {{"Class", "class.lua"}, {"Point", "point.lua"}}
for i=1, #external do
local external = { { "Class", "class.lua" }, { "Point", "point.lua" } }
for i = 1, #external do
local module = external[i]
local path = string.format("client/imports/%s", module[2])
@@ -78,7 +78,7 @@ else
return
end
return setmetatable({src = src}, {
return setmetatable({ src = src }, {
__index = function(self, method)
return function(...)
return exports.es_extended:RunStaticPlayerMethod(self.src, method, ...)
@@ -87,6 +87,11 @@ else
})
end
})
AddEventHandler("esx:jobsLoaded", function()
ESX.JobsLoaded = true
end)
end
if GetResourceState("ox_lib") == "missing" then
+1
View File
@@ -1,6 +1,7 @@
ESX.Players = {}
ESX.Jobs = {}
ESX.Items = {}
ESX.JobsLoaded = false
Core = {}
Core.JobsPlayerCount = {}
Core.UsableItemsCallbacks = {}
+5 -3
View File
@@ -445,7 +445,7 @@ function ESX.DiscordLog(name, title, color, message)
}
PerformHttpRequest(
webHook,
function ()
function()
return
end,
"POST",
@@ -489,7 +489,7 @@ function ESX.DiscordLogFields(name, title, color, fields)
}
PerformHttpRequest(
webHook,
function ()
function()
return
end,
"POST",
@@ -536,6 +536,8 @@ function ESX.RefreshJobs()
else
ESX.Jobs = Jobs
end
TriggerEvent("esx:jobsLoaded")
end
---@param item string
@@ -790,5 +792,5 @@ end
---@param plate string
---@return CExtendedVehicle?
function ESX.GetExtendedVehicleFromPlate(plate)
return Core.vehicleClass.getFromPlate(plate)
return Core.vehicleClass.getFromPlate(plate)
end