From 2236163d5ca5397cc7dc6709c843ae35a8ec53ce Mon Sep 17 00:00:00 2001 From: Mojito-Fivem Date: Sun, 7 Nov 2021 22:44:39 +0000 Subject: [PATCH] feat(server/functions): GetPlayersOnDuty Co-authored-by: Solositeous <36283056+Solositeous@users.noreply.github.com> --- server/functions.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/functions.lua b/server/functions.lua index 2f78ebf..ec98de6 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -76,6 +76,22 @@ end function QBCore.Functions.GetQBPlayers() return QBCore.Players end + +function QBCore.Functions.GetPlayersOnDuty(job) + local players = {} + local count = 0 + + for src, Player in pairs(QBCore.Players) do + if Player.PlayerData.job.name == job then + if Player.PlayerData.job.onduty then + players[#players + 1] = src + count = count + 1 + end + end + end + return players, count +end + -- Paychecks (standalone - don't touch) function PaycheckLoop()