diff --git a/resources/[standalone]/ps-multijob/server/sv_main.lua b/resources/[standalone]/ps-multijob/server/sv_main.lua index 4cb5dfe53..5de149b33 100644 --- a/resources/[standalone]/ps-multijob/server/sv_main.lua +++ b/resources/[standalone]/ps-multijob/server/sv_main.lua @@ -182,6 +182,7 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb) local active = {} local getjobs = {} local Players = QBCore.Functions.GetPlayers() + local invalidJobs = {} -- Track invalid jobs for potential cleanup for i = 1, #Players, 1 do local xPlayer = QBCore.Functions.GetPlayer(Players[i]) @@ -193,7 +194,11 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb) for job, grade in pairs(jobs) do if QBCore.Shared.Jobs[job] == nil then - print("The job '" .. job .. "' has been removed and is not present in your QBCore jobs. Remove it from the multijob SQL or add it back to your qbcore jobs.lua.") + -- Instead of just printing, add to invalid jobs list + -- but don't immediately remove - could be loaded later by jobs_creator + invalidJobs[job] = true + -- Still print for debugging + print("Warning: Job '" .. job .. "' not found in QBCore.Shared.Jobs. It may be loaded later by jobs_creator.") else local online = active[job] or 0 getjobs = { @@ -221,6 +226,7 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb) cb(multijobs) end) + RegisterNetEvent("ps-multijob:changeJob",function(cjob, cgrade) local source = source local Player = QBCore.Functions.GetPlayer(source) @@ -278,3 +284,13 @@ RegisterNetEvent('QBCore:Server:OnJobUpdate', function(source, newJob) end end end) +RegisterNetEvent('QBCore:Server:OnJobUpdate', function(source, newJob) + -- Existing code... +end) + +-- Add the new event listener here, at the bottom of the file +RegisterNetEvent("jobs_creator:injectJobs", function(jobs) + -- This will run when jobs are injected, allowing ps-multijob to know about new jobs + print("ps-multijob: Jobs have been updated by jobs_creator") + -- You could potentially refresh any cached job data here +end) \ No newline at end of file