> 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/items.md).

# Items

Provides a way to register and trigger usable item logic server-side. This module allows developers to define behaviour when an item is used in-game.

***

## Accessing the Module

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

***

## Server

### register\_item(item\_id, use\_function)

Registers an item as usable. When the item is used, the callback function will be invoked with the source and item ID.

#### Parameters

| Name          | Type       | Description                        |
| ------------- | ---------- | ---------------------------------- |
| item\_id      | `string`   | The item identifier                |
| use\_function | `function` | The function to call on item usage |

#### Example

```lua
ITEMS.register_item("firstaid", function(source, item_id)
    print("Used item:", item_id, "by player:", source)
end)
```

***

### use\_item(source, item\_id)

Triggers a previously registered usable item for the player.

#### Parameters

| Name     | Type     | Description                  |
| -------- | -------- | ---------------------------- |
| source   | `number` | The player source identifier |
| item\_id | `string` | The item identifier to use   |

#### Example

```lua
ITEMS.use_item(source, "firstaid")
```


---

# 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/items.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.
