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