forked from Simnation/Main
fix
This commit is contained in:
parent
aaecab3084
commit
2b3f79d459
3 changed files with 49 additions and 11 deletions
|
@ -72,3 +72,19 @@ RegisterCommand("jobmenu", OpenUI, false)
|
|||
RegisterKeyMapping('jobmenu', "Show Job Management", "keyboard", "J")
|
||||
|
||||
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)
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
@ -294,3 +291,19 @@ RegisterNetEvent("jobs_creator:injectJobs", function(jobs)
|
|||
print("ps-multijob: Jobs have been updated by jobs_creator")
|
||||
-- You could potentially refresh any cached job data here
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue