Skip to content

Commit

Permalink
Update main.lua
Browse files Browse the repository at this point in the history
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
1 parent 4c77679 commit a6441a4
Showing 1 changed file with 4 additions and 8 deletions.
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)

0 comments on commit a6441a4

Please sign in to comment.