> For the complete documentation index, see [llms.txt](https://docs.hyper-code.eu/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyper-code.eu/documentation/inventory/exports-and-events.md).

# Inventory – Exports & events

Client and server exports and events of Inventory (hc\_inventory): open inventory, vehicle storage, job storage, external stashes and frisk.

## Open inventory (client)

### openInventory

Opens the player's inventory.

```lua
exports['hc_inventory']:openInventory()
```

### openTrunk

Opens the trunk of the closest vehicle (within 2.5 m), or the glovebox if the player sits in the driver or front passenger seat.

```lua
exports['hc_inventory']:openTrunk()
```

## Vehicle storage (server)

```lua
exports['hc_inventory']:vehicleInventoryAddItem(plate, type, itemname, count)
exports['hc_inventory']:vehicleInventoryRemoveItem(plate, type, itemname, count)
```

| Argument   | Type     | Description                                                             |
| ---------- | -------- | ----------------------------------------------------------------------- |
| `plate`    | `string` | Plate of the vehicle, exactly as `GetVehicleNumberPlateText` returns it |
| `type`     | `string` | `"trunk"` or `"glovebox"`                                               |
| `itemname` | `string` | Item name                                                               |
| `count`    | `number` | Amount                                                                  |

**Returns:** nothing.

{% hint style="info" %}
The vehicle must exist in the world and its trunk or glovebox must already be loaded (opened at least once since the vehicle spawned). Otherwise the call does nothing.
{% endhint %}

## Job storage (server)

```lua
exports['hc_inventory']:jobInventoryAddItem(jobname, itemname, count)
exports['hc_inventory']:jobInventoryRemoveItem(jobname, itemname, count)
```

| Argument   | Type     | Description                                                           |
| ---------- | -------- | --------------------------------------------------------------------- |
| `jobname`  | `string` | ESX job name. The job must be configured in `Config.Jobstorage.Jobs`. |
| `itemname` | `string` | Item name, or `"money"` for cash                                      |
| `count`    | `number` | Amount                                                                |

**Returns:** nothing.

Example: put 500 cash into the police storage.

```lua
exports['hc_inventory']:jobInventoryAddItem('police', 'money', 500)
```

## External stashes

### externalInventoryOpen (server)

Opens a stash for a player. The stash is created on first use and saved in `external_storages`.

```lua
exports['hc_inventory']:externalInventoryOpen(source, uniqueid, data)
```

| Argument         | Type     | Description                                                                 |
| ---------------- | -------- | --------------------------------------------------------------------------- |
| `source`         | `number` | Server ID of the player                                                     |
| `uniqueid`       | `string` | Unique ID of the stash (max. 50 characters), for example `"house_12"`       |
| `data`           | `table`  | Options for the stash (fields below)                                        |
| `data.title`     | `string` | Title of the stash. Default: `Config.ExternalStashes.DefaultInventoryTitle` |
| `data.maxweight` | `number` | Maximum weight. Default: `99999`                                            |
| `data.slots`     | `number` | Maximum number of slots. Default: no limit                                  |

**Returns:** nothing.

Example for a housing script:

```lua
exports['hc_inventory']:externalInventoryOpen(source, 'house_' .. houseId, {
    title = 'House storage',
    maxweight = 200,
    slots = 30
})
```

### hc\_inventory:openExternalStash (client → server)

The same as the export, triggered from the client. The player who triggers it opens the stash.

```lua
TriggerServerEvent('hc_inventory:openExternalStash', uniqueid, { title = 'House storage', maxweight = 200, slots = 30 })
```

{% hint style="warning" %}
Prefer the server export. Check on the server that the player may open the stash (for example owns the house) before you call it.
{% endhint %}

### externalInventoryAddItem / externalInventoryRemoveItem (server)

```lua
exports['hc_inventory']:externalInventoryAddItem(uniqueid, itemname, count)
exports['hc_inventory']:externalInventoryRemoveItem(uniqueid, itemname, count)
```

| Argument   | Type     | Description            |
| ---------- | -------- | ---------------------- |
| `uniqueid` | `string` | Unique ID of the stash |
| `itemname` | `string` | Item name              |
| `count`    | `number` | Amount                 |

**Returns:** nothing.

Works only for stashes that have been opened since the last server start. Otherwise the call does nothing.

## Frisk

### hc\_inventory:friskPlayer (client event)

Opens the inventory of another player as a second inventory for the local player.

```lua
-- client side
TriggerEvent('hc_inventory:friskPlayer', targetServerId)

-- server side
TriggerClientEvent('hc_inventory:friskPlayer', source, targetServerId)
```

| Argument         | Type     | Description                            |
| ---------------- | -------- | -------------------------------------- |
| `targetServerId` | `number` | Server ID of the player who is frisked |

Check in your own script that the player is allowed to frisk (job, distance, target handcuffed) before triggering it.
