# Police

Functions for checking how many police officers are online.

***

## GetCopCount

Returns the number of players currently working a police job.

```lua
local count = KOJA.Server.GetCopCount()
```

**Returns** `number`

Also available as an export:

```lua
local count = exports['koja-lib']:getCopCount()
```

***

## Configuration

Which jobs count as police is controlled by `Config.PoliceGroups`:

```lua
-- editable/shared/config.lua
Config.PoliceGroups = {
    ["police"]  = true,
    ["sheriff"] = true,
    ["swat"]    = true,
}
```

***

## Examples

```lua
-- Gate an action behind a minimum cop count
local cops = KOJA.Server.GetCopCount()

if cops < 2 then
    KOJA.Server.SendNotify({
        source = source,
        type   = 'error',
        desc   = 'At least 2 police officers must be online.',
    })
    return
end
```

***

## Callback

The cop count is also exposed as a server callback for client scripts:

```lua
-- Client
KOJA.Client.TriggerServerCallback('koja-heistlib:Server:getCopCount', nil, function(data)
    print('Cops online:', data.count)
end)
```

## Related pages

- [Callbacks](/koja-lib/api-reference/server-api/callbacks) — The callback system allows server scripts to handle requests from clients and vice versa.
- [Licenses](/koja-lib/api-reference/server-api/licenses) — Check whether a player holds a specific driving or skill license.
- [Money](/koja-lib/api-reference/server-api/money) — Functions for reading and modifying a player's money on the server.
- [Inventory](/koja-lib/api-reference/server-api/inventory) — Server-side inventory functions.
- [Notifications](/koja-lib/api-reference/server-api/notifications) — Send notifications to a player from the server side.
- [Player](/koja-lib/api-reference/server-api/player) — Functions for reading player information on the server.
- [Server API](/koja-lib/api-reference/server-api) — back to the section overview
