1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-11 23:43:42 +02:00
parent aa78a2febb
commit 7dfe792351
2 changed files with 76 additions and 0 deletions

View file

@ -1,5 +1,7 @@
local QBCore = exports['qb-core']:GetCoreObject()
local isJobMenuOpen = false
local lastJobCheck = 0
local checkInterval = 60000 -- Check for new jobs every 60 seconds
local function GetJobs()
local p = promise.new()
@ -20,6 +22,19 @@ local function OpenUI()
jobs = GetJobs(),
side = Config.Side,
})
lastJobCheck = GetGameTimer() -- Reset the timer when we open the UI
end
-- Function to check for job updates
local function CheckForJobUpdates()
if isJobMenuOpen and (GetGameTimer() - lastJobCheck) > checkInterval then
lastJobCheck = GetGameTimer()
local jobs = GetJobs()
SendNUIMessage({
action = 'updateJobList',
jobs = jobs
})
end
end
RegisterNUICallback('selectjob', function(data, cb)
@ -81,3 +96,19 @@ RegisterNetEvent('ps-multijob:refreshJobs', function()
OpenUI() -- Refresh the UI with updated job data
end
end)
-- Request job updates from server periodically
Citizen.CreateThread(function()
while true do
Citizen.Wait(checkInterval)
TriggerServerEvent('ps-multijob:requestJobUpdate')
end
end)
-- Check for job updates while menu is open
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000) -- Check every second if we need to update
CheckForJobUpdates()
end
end)