1
0
Fork 0
forked from Simnation/Main

Update sv_main.lua

This commit is contained in:
Nordi98 2025-07-01 06:06:36 +02:00
parent 54d2199a10
commit 632c3af258

View file

@ -182,6 +182,7 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
local active = {} local active = {}
local getjobs = {} local getjobs = {}
local Players = QBCore.Functions.GetPlayers() local Players = QBCore.Functions.GetPlayers()
local invalidJobs = {} -- Track invalid jobs for potential cleanup
for i = 1, #Players, 1 do for i = 1, #Players, 1 do
local xPlayer = QBCore.Functions.GetPlayer(Players[i]) 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 for job, grade in pairs(jobs) do
if QBCore.Shared.Jobs[job] == nil then 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 else
local online = active[job] or 0 local online = active[job] or 0
getjobs = { getjobs = {
@ -221,6 +226,7 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
cb(multijobs) cb(multijobs)
end) end)
RegisterNetEvent("ps-multijob:changeJob",function(cjob, cgrade) RegisterNetEvent("ps-multijob:changeJob",function(cjob, cgrade)
local source = source local source = source
local Player = QBCore.Functions.GetPlayer(source) local Player = QBCore.Functions.GetPlayer(source)
@ -278,3 +284,13 @@ RegisterNetEvent('QBCore:Server:OnJobUpdate', function(source, newJob)
end end
end 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)