diff --git a/resources/[standalone]/ps-multijob/client/cl_main.lua b/resources/[standalone]/ps-multijob/client/cl_main.lua index 8974a48c6..28c86f79e 100644 --- a/resources/[standalone]/ps-multijob/client/cl_main.lua +++ b/resources/[standalone]/ps-multijob/client/cl_main.lua @@ -71,4 +71,20 @@ RegisterCommand("jobmenu", OpenUI, false) RegisterKeyMapping('jobmenu', "Show Job Management", "keyboard", "J") -TriggerEvent('chat:removeSuggestion', '/jobmenu') \ No newline at end of file +TriggerEvent('chat:removeSuggestion', '/jobmenu') + + +-- Add this to cl_main.lua +RegisterNetEvent('ps-multijob:refreshJobs', function() + if not IsPauseMenuActive() then -- Only refresh if menu is open + local isMenuOpen = false + -- Check if the NUI is focused (menu is open) + if IsPauseMenuActive() and IsPauseMenuRestarting() then + isMenuOpen = true + end + + if isMenuOpen then + OpenUI() -- Refresh the UI with updated job data + end + end +end) \ No newline at end of file diff --git a/resources/[standalone]/ps-multijob/config.lua b/resources/[standalone]/ps-multijob/config.lua index 41468e4b7..72685cb48 100644 --- a/resources/[standalone]/ps-multijob/config.lua +++ b/resources/[standalone]/ps-multijob/config.lua @@ -58,3 +58,12 @@ Config.FontAwesomeIcons = { ["vineyard"] = "fa-solid fa-wine-bottle", ["hotdog"] = "fa-solid fa-hotdog", } + +-- Add this function at the end of config.lua +function Config.GetJobDescription(jobName) + return Config.Descriptions[jobName] or "No description available" +end + +function Config.GetJobIcon(jobName) + return Config.FontAwesomeIcons[jobName] or "fa-solid fa-briefcase" +end diff --git a/resources/[standalone]/ps-multijob/server/sv_main.lua b/resources/[standalone]/ps-multijob/server/sv_main.lua index 5de149b33..f6ff3a4f5 100644 --- a/resources/[standalone]/ps-multijob/server/sv_main.lua +++ b/resources/[standalone]/ps-multijob/server/sv_main.lua @@ -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) \ No newline at end of file +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)