From a6441a4e27fce83b9d91c566c18b6bf749a1defa Mon Sep 17 00:00:00 2001 From: JericoFX <56100605+JericoFX@users.noreply.github.com> Date: Wed, 8 Mar 2023 00:15:59 -0300 Subject: [PATCH] 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) --- server/main.lua | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/server/main.lua b/server/main.lua index 062fc0a..79e591e 100644 --- a/server/main.lua +++ b/server/main.lua @@ -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) \ No newline at end of file + local amount = QBCore.Functions.GetDutyCount("police") + CachedPolice[src] = amount + cb(amount) +end)