forked from Simnation/Main
fix
This commit is contained in:
parent
aaecab3084
commit
2b3f79d459
3 changed files with 49 additions and 11 deletions
|
@ -71,4 +71,20 @@ RegisterCommand("jobmenu", OpenUI, false)
|
||||||
|
|
||||||
RegisterKeyMapping('jobmenu', "Show Job Management", "keyboard", "J")
|
RegisterKeyMapping('jobmenu', "Show Job Management", "keyboard", "J")
|
||||||
|
|
||||||
TriggerEvent('chat:removeSuggestion', '/jobmenu')
|
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",
|
["vineyard"] = "fa-solid fa-wine-bottle",
|
||||||
["hotdog"] = "fa-solid fa-hotdog",
|
["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
|
||||||
end, 'admin')
|
end, 'admin')
|
||||||
|
|
||||||
|
|
||||||
QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
|
QBCore.Functions.CreateCallback("ps-multijob:getJobs", function(source, cb)
|
||||||
local Player = QBCore.Functions.GetPlayer(source)
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
local jobs = GetJobs(Player.PlayerData.citizenid)
|
local jobs = GetJobs(Player.PlayerData.citizenid)
|
||||||
|
@ -182,7 +183,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
|
local pendingJobs = {} -- Track jobs that might be loaded later
|
||||||
|
|
||||||
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])
|
||||||
|
@ -194,18 +195,15 @@ 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
|
||||||
-- Instead of just printing, add to invalid jobs list
|
-- Instead of showing a warning, store this job for later processing
|
||||||
-- but don't immediately remove - could be loaded later by jobs_creator
|
pendingJobs[job] = grade
|
||||||
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 = {
|
||||||
name = job,
|
name = job,
|
||||||
grade = grade,
|
grade = grade,
|
||||||
description = Config.Descriptions[job],
|
description = Config.Descriptions[job] or "No description available",
|
||||||
icon = Config.FontAwesomeIcons[job],
|
icon = Config.FontAwesomeIcons[job] or "fa-solid fa-briefcase", -- Default icon
|
||||||
label = QBCore.Shared.Jobs[job].label,
|
label = QBCore.Shared.Jobs[job].label,
|
||||||
gradeLabel = QBCore.Shared.Jobs[job].grades[tostring(grade)].name,
|
gradeLabel = QBCore.Shared.Jobs[job].grades[tostring(grade)].name,
|
||||||
salary = QBCore.Shared.Jobs[job].grades[tostring(grade)].payment,
|
salary = QBCore.Shared.Jobs[job].grades[tostring(grade)].payment,
|
||||||
|
@ -226,7 +224,6 @@ 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)
|
||||||
|
@ -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
|
-- 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")
|
print("ps-multijob: Jobs have been updated by jobs_creator")
|
||||||
-- You could potentially refresh any cached job data here
|
-- 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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue