qb-core icon indicating copy to clipboard operation
qb-core copied to clipboard

feat: add GetOnDuty exports

Open Cocodrulo opened this issue 10 months ago • 7 comments

Description

Added GetOnDuty exports both client and server side. In order to add this QBCore.Functions.GetOnDuty was added client-side and a callback was added server-side.

-- Client side
local cops_func = QBCore.Functions.GetDutyCount('police') -- int
local cops_exp = exports['qb-core']:GetDutyCount('police') -- int

-- Server side
local cops_func = QBCore.Functions.GetDutyCount('police') -- int
local cops_exp = exports['qb-core']:GetDutyCount('police') -- int

Checklist

  • [ ] I have personally loaded this code into an updated qbcore project and checked all of its functionality.
  • [x] My code fits the style guidelines.
  • [x] My PR fits the contribution guidelines.

Cocodrulo avatar Jan 09 '25 11:01 Cocodrulo

one thing i would add is a check to see if job has a type attached

so like

if QBCore.Shared.Jobs[job].type == nil then 
  check logic for name 
else
   Check logic for type 
 end

so that way it will pool all people that can do those jobs

or even a bool as a second param so people can do something like

QBCore.Functions.GetOnDuty('police', true)
and it would check if param2 then check by type assigned to police
if false or nil then check by name

Mustachedom avatar Jan 10 '25 06:01 Mustachedom

Added! (I think)

Cocodrulo avatar Jan 10 '25 21:01 Cocodrulo

Suggestion: Utilize QBCore:Client:OnPlayerLoaded and QBCore:Client:OnJobUpdate to update the number of duty jobs and store it in the global statebag instead of loop from the table when the function is called, that will make the data can be accessed from both the server side and client side.

alfaritsii avatar Jan 12 '25 07:01 alfaritsii

Well, idk if thats a better solution, it to messy I think, but i'll look into it?

Cocodrulo avatar Jan 12 '25 13:01 Cocodrulo

the global state bag is a good addition, but is shud make into the core itself so you can return later GlobalState[jobname]

JericoFX avatar Jan 27 '25 10:01 JericoFX

IDK really, I think is messier, but I'll look into it

Cocodrulo avatar Jan 27 '25 19:01 Cocodrulo

Added the use of statebags, let me know what you think

Cocodrulo avatar Feb 03 '25 10:02 Cocodrulo

I added exports for all qb functions

GhzGarage avatar Jun 22 '25 20:06 GhzGarage