Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GetOnDuty exports #1162

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Cocodrulo
Copy link
Contributor

@Cocodrulo Cocodrulo commented Jan 9, 2025

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.
  • My code fits the style guidelines.
  • My PR fits the contribution guidelines.

@Mustachedom
Copy link
Contributor

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

@Cocodrulo
Copy link
Contributor Author

Added! (I think)

@alfaritsii
Copy link

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.

@Cocodrulo
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants