1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-02 07:37:36 +02:00
parent aaecab3084
commit 2b3f79d459
3 changed files with 49 additions and 11 deletions

View file

@ -173,6 +173,7 @@ QBCore.Commands.Add('addjob', 'Add Multi Job (Admin Only)', { { name = 'id', hel
end
end, 'admin')
QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
local Player = QBCore.Functions.GetPlayer(source)
local jobs = GetJobs(Player.PlayerData.citizenid)
@ -182,7 +183,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
local pendingJobs = {} -- Track jobs that might be loaded later
for i = 1, #Players, 1 do
local xPlayer = QBCore.Functions.GetPlayer(Players[i])
@ -194,18 +195,15 @@ QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
for job, grade in pairs(jobs) do
if QBCore.Shared.Jobs[job] == nil then
-- 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.")
-- Instead of showing a warning, store this job for later processing
pendingJobs[job] = grade
else
local online = active[job] or 0
getjobs = {
name = job,
grade = grade,
description = Config.Descriptions[job],
icon = Config.FontAwesomeIcons[job],
description = Config.Descriptions[job] or "No description available",
icon = Config.FontAwesomeIcons[job] or "fa-solid fa-briefcase", -- Default icon
label = QBCore.Shared.Jobs[job].label,
gradeLabel = QBCore.Shared.Jobs[job].grades[tostring(grade)].name,
salary = QBCore.Shared.Jobs[job].grades[tostring(grade)].payment,
@ -226,7 +224,6 @@ 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)
@ -293,4 +290,20 @@ 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)
end)
-- Add this near the bottom of sv_main.lua
RegisterNetEvent("jobs_creator:injectJobs", function(jobs)
-- This will run when jobs are injected by jobs_creator
print("ps-multijob: Jobs have been updated by jobs_creator")
-- Optional: You could notify online players that jobs have been updated
-- This would allow them to refresh their job menu to see any new jobs
local Players = QBCore.Functions.GetPlayers()
for i = 1, #Players do
local Player = QBCore.Functions.GetPlayer(Players[i])
if Player then
TriggerClientEvent('QBCore:Notify', Players[i], "Job system has been updated", "success")
end
end
end)