Skip to content

Commit

Permalink
fix(client/groups): require data on startup
Browse files Browse the repository at this point in the history
for slow machines my beloved <3
  • Loading branch information
ChatDisabled committed Feb 10, 2025
1 parent 5704436 commit 92021e2
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions client/groups.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
local jobs, gangs

local function refreshCache()
local groups = lib.callback.await('qbx_core:server:getGroups')
jobs = groups.jobs
gangs = groups.gangs
end
local jobs = require 'shared.jobs'
local gangs = require 'shared.gangs'

---@return table<string, Job>
function GetJobs()
if not jobs then refreshCache() end
return jobs
end

exports('GetJobs', GetJobs)

---@return table<string, Gang>
function GetGangs()
if not gangs then refreshCache() end
return gangs
end

Expand All @@ -25,7 +18,6 @@ exports('GetGangs', GetGangs)
---@param name string
---@return Job?
function GetJob(name)
if not jobs then refreshCache() end
return jobs[name]
end

Expand All @@ -34,7 +26,6 @@ exports('GetJob', GetJob)
---@param name string
---@return Gang?
function GetGang(name)
if not gangs then refreshCache() end
return gangs[name]
end

Expand All @@ -47,3 +38,7 @@ end)
RegisterNetEvent('qbx_core:client:onGangUpdate', function(gangName, gang)
gangs[gangName] = gang
end)

local groups = lib.callback.await('qbx_core:server:getGroups')
jobs = groups.jobs
gangs = groups.gangs

0 comments on commit 92021e2

Please sign in to comment.