# Licences

Provides a standalone licence system supporting driving, weapon, hunting licences and more, with support for points and revocation. Framework-agnostic.

***

## Accessing the Module

```lua
local LICENCES <const> = exports.boii_utils:get("modules.licences")
```

***

## Server

### get\_licences(source)

Retrieves all licences for a player.

#### Parameters

| Name   | Type     | Description              |
| ------ | -------- | ------------------------ |
| source | `number` | Player source identifier |

#### Example

```lua
local all_licences = LICENCES.get_all(source)
```

***

### get\_licence(source, licence\_id)

Retrieves a specific licence for a player.

#### Parameters

| Name        | Type     | Description              |
| ----------- | -------- | ------------------------ |
| source      | `number` | Player source identifier |
| licence\_id | `string` | Licence ID               |

#### Example

```lua
local weapon_licence = LICENCES.get(source, "weapon")
```

***

### add\_licence(source, licence\_id)

Grants a player a new licence.

#### Parameters

| Name        | Type     | Description       |
| ----------- | -------- | ----------------- |
| source      | `number` | Player source ID  |
| licence\_id | `string` | Licence ID to add |

#### Example

```lua
LICENCES.add(source, "driver")
```

***

### remove\_licence(source, licence\_id)

Removes a player's licence.

#### Parameters

| Name        | Type     | Description          |
| ----------- | -------- | -------------------- |
| source      | `number` | Player source ID     |
| licence\_id | `string` | Licence ID to remove |

#### Example

```lua
LICENCES.remove(source, "driver")
```

***

### add\_points(source, licence\_id, points)

Adds penalty points to a player's licence.

#### Parameters

| Name        | Type     | Description          |
| ----------- | -------- | -------------------- |
| source      | `number` | Player source ID     |
| licence\_id | `string` | Licence ID to modify |
| points      | `number` | Points to add        |

#### Example

```lua
LICENCES.add_points(source, "driver", 3)
```

***

### remove\_points(source, licence\_id, points)

Removes penalty points from a player's licence.

#### Parameters

| Name        | Type     | Description          |
| ----------- | -------- | -------------------- |
| source      | `number` | Player source ID     |
| licence\_id | `string` | Licence ID to modify |
| points      | `number` | Points to remove     |

#### Example

```lua
LICENCES.remove_points(source, "driver", 2)
```

***

### update\_licence(source, licence\_id, test\_type, passed)

Updates a licence to mark theory or practical passed.

#### Parameters

| Name        | Type      | Description                        |
| ----------- | --------- | ---------------------------------- |
| source      | `number`  | Player source ID                   |
| licence\_id | `string`  | Licence ID to update               |
| test\_type  | `string`  | Either `"theory"` or `"practical"` |
| passed      | `boolean` | `true` if passed, `false` if not   |

#### Example

```lua
LICENCES.update(source, "driver", "practical", true)
```

***

## Client

### get\_licences()

Triggers server callback to fetch current player's licences.

#### Parameters

None

#### Example

```lua
LICENCES.get_all(function(data)
    print(json.encode(data))
end)
```


---

# Agent Instructions: 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:

```
GET https://docs.boii.dev/old-docs/boii_utils/api/licences.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
