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

Update main.lua #6

Merged
merged 1 commit into from
Mar 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update main.lua
In the lastest version of qbcore there is already a function to track the amount of people who is on duty, there is another one that return the players and the amount of players on duty
QBCore.Functions.GetPlayersOnDuty(job)
  • Loading branch information
JericoFX committed Mar 8, 2023
commit a6441a4e27fce83b9d91c566c18b6bf749a1defa
12 changes: 4 additions & 8 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ end)
QBCore.Functions.CreateCallback('g-drugselling:server:getCopCount', function(source, cb)
local src = source
local policeCount = 0
for _, v in pairs(QBCore.Functions.GetQBPlayers()) do
if v.PlayerData.job.name == "police" and v.PlayerData.job.onduty then
policeCount = policeCount + 1
end
end
CachedPolice[src] = policeCount
cb(policeCount)
end)
local amount = QBCore.Functions.GetDutyCount("police")
CachedPolice[src] = amount
cb(amount)
end)