> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/koja-lib/api-reference/server-api/police.md).

# 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)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kojascripts.eu/koja-lib/api-reference/server-api/police.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
