diff --git a/server/functions.lua b/server/functions.lua index 2f78ebf..1ff1e71 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -76,6 +76,37 @@ end function QBCore.Functions.GetQBPlayers() return QBCore.Players end + +--- Gets a list of all on duty players of a specified job and the number +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 + +-- Returns only the amount of players on duty for the specified job +function QBCore.Functions.GetDutyCount(job) + local count = 0 + + for _, Player in pairs(QBCore.Players) do + if Player.PlayerData.job.name == job then + if Player.PlayerData.job.onduty then + count = count + 1 + end + end + end + return count +end + -- Paychecks (standalone - don't touch) function PaycheckLoop()