> For the complete documentation index, see [llms.txt](https://docs.boii.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.boii.dev/old-docs/boii_utils/api/xp.md).

# XP

Handles player XP tracking, leveling, and data persistence for skills, reputation, and other growth systems.

***

## Accessing the Module

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

***

## Server

### get\_all\_xp(source)

Retrieves all XP data for a player.

#### Parameters

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

#### Returns

| Type  | Description         |
| ----- | ------------------- |
| table | Table of XP entries |

#### Example

```lua
local all_xp = XP.get_all(source)
```

***

### get\_xp(source, xp\_id)

Gets a specific XP entry for a player.

#### Parameters

| Name   | Type     | Description      |
| ------ | -------- | ---------------- |
| source | `number` | Player source ID |
| xp\_id | `string` | The XP ID        |

#### Returns

| Type  | Description        |
| ----- | ------------------ |
| table | XP data for the ID |

#### Example

```lua
local fishing = XP.get(source, "fishing")
```

***

### set\_xp(source, xp\_id, amount)

Sets a player's XP to a fixed value.

#### Parameters

| Name   | Type     | Description            |
| ------ | -------- | ---------------------- |
| source | `number` | Player source ID       |
| xp\_id | `string` | The XP ID              |
| amount | `number` | Amount of XP to assign |

#### Example

```lua
XP.set(source, "fishing", 100)
```

***

### add\_xp(source, xp\_id, amount)

Adds XP to a player's skill and handles level-ups.

#### Parameters

| Name   | Type     | Description         |
| ------ | -------- | ------------------- |
| source | `number` | Player source ID    |
| xp\_id | `string` | The XP ID           |
| amount | `number` | Amount of XP to add |

#### Example

```lua
XP.add(source, "fishing", 10)
```

***

### remove\_xp(source, xp\_id, amount)

Removes XP from a player's skill and handles level-downs.

#### Parameters

| Name   | Type     | Description              |
| ------ | -------- | ------------------------ |
| source | `number` | Player source ID         |
| xp\_id | `string` | The XP ID                |
| amount | `number` | Amount of XP to subtract |

#### Example

```lua
XP.remove(source, "fishing", 5)
```

***

## Client

### get\_all\_xp()

Requests all XP data for the local player.

#### Returns

| Type  | Description        |
| ----- | ------------------ |
| table | XP data for player |

#### Example

```lua
local xp_data = XP.get_all()
```


---

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

```
GET https://docs.boii.dev/old-docs/boii_utils/api/xp.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.
