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

[Feature Request] - es_extended - include duty status in job statebag counter #1536

Open
Maximus7474 opened this issue Dec 10, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Maximus7474
Copy link

Describe the Feature

With the new version (1.11.*) and the integration of job duty, it would be useful to alter the data in ESX.JobsPlayerCount to not only reflect the number of connected players with the job but also players with the job active.

This could also be done with another system in parallel with an object called something like ESX.JobsOnDutyPlayerCount.

Screenshots

This is only rough idea to detail the imagined concept

AddEventHandler("esx:setJob", function(_, job, lastJob)
    local lastJobKey = ("%s:count"):format(lastJob.name)
    local jobKey = ("%s:count"):format(job.name)

    local currentLastJob = ESX.JobsPlayerCount[lastJob.name] or {players: 0, onDuty: 0}
    local currentNewJob = ESX.JobsPlayerCount[lastJob.name] or {players: 0, onDuty: 0}

    ESX.JobsPlayerCount[lastJob.name] = {
        players: currentLastJob - 1,
        onDuty: currentLastJob - (lastJob.onDuty and 1 or 0)
    }

    ESX.JobsPlayerCount[job.name] = {
        players: currentNewJob + 1,
        onDuty: currentNewJob + (job.onDuty and 1 or 0)
    }

    GlobalState[lastJobKey] = ESX.JobsPlayerCount[lastJob.name]
    GlobalState[jobKey] = ESX.JobsPlayerCount[job.name]
end)

Additional context

This can be very useful for scripts that check if any players are on duty to allow/deny the use of certain functionalities.

@Maximus7474 Maximus7474 added the enhancement New feature or request label Dec 10, 2024
@github-project-automation github-project-automation bot moved this to 🆕 To be Discussed in ESX Roadmap Dec 10, 2024
@Maximus7474
Copy link
Author

Having not used or followed esx development recently I'm unsure of how widespread this system is.
I have also noted the severity that this breaking change suggestion can bring in.

@Kenshiin13
Copy link
Contributor

To maintain compatibility, we would need to introduce a second global state for each job to track the on-duty player count. Personally, I'm not sure if that is a good idea. Do you have a specific use case in mind? Alternatively, we could add a config option to only reflect on-duty players in the job player count?

@Maximus7474
Copy link
Author

Just a general Idea following some support given on lb-phone which checks the players on duty to determine if a company is open or not.
A general idea which I thought could be interesting to evoke and has a couple of other uses.
Such as:

  • Robbery Scripts requiring X police players on duty to use
  • An automatic response on a bell if no players are on duty

it's limited use but could be something interesting.

@Kenshiin13
Copy link
Contributor

@Maximus7474 I'm planning to add an internal player job cache anyways. We could expose a function to retrieve the number of players on duty for a given job. Would that solve your issue?

@Maximus7474
Copy link
Author

Sounds like à good solution, I wouldn't call it an issue more like à thought to improve the system.

@Mycroft-Studios Mycroft-Studios moved this from 🆕 To be Discussed to To Be Assigned in ESX Roadmap Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: To Be Assigned
Development

No branches or pull requests

4 participants