> For the complete documentation index, see [llms.txt](https://atiysus-organization.gitbook.io/aty-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atiysus-organization.gitbook.io/aty-scripts/inventory/developers/exports.md).

# Exports

## Exports

All server exports are on `exports.aty_inventory`. Client exports are on the same name, client-side.

#### Reading

| Export                                                                                                                        | Returns                                           |
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| `GetInventory(inv)`                                                                                                           | The whole container                               |
| `GetInventoryItems(inv)`                                                                                                      | Its items                                         |
| `GetInventoryWeight(inv)` / `GetInventoryMaxWeight(inv)`                                                                      | Grams used / allowed                              |
| `GetTotalWeight(items)` / `GetFreeWeight(inv)`                                                                                | Grams in a qb-shaped item table / grams remaining |
| `GetItem(inv, name)` / `GetItemByName(inv, name)`                                                                             | First match                                       |
| `GetItemsByName(inv, name)`                                                                                                   | All matches                                       |
| `GetItemBySlot(inv, slot)` / `GetSlot(inv, slot)`                                                                             | What is in a slot                                 |
| `GetItemCount(inv, name)`                                                                                                     | How many                                          |
| `GetSlots(inv)` / `GetSlotUsage(inv)`                                                                                         | Slot counts                                       |
| `GetSlotWithItem` · `GetSlotIdWithItem` · `GetSlotsWithItem` · `GetSlotIdsWithItem` · `GetSlotsByItem` · `GetFirstSlotByItem` | Slot lookups                                      |
| `HasItem(inv, name, count)`                                                                                                   | Boolean                                           |
| `InventoryExists(inv)`                                                                                                        | Boolean                                           |
| `Items()`                                                                                                                     | The item catalogue                                |

#### Writing

| Export                                              | Does                                                                                                     |
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `AddItem(inv, name, count, metadata)`               | Add. Refused if it would not fit                                                                         |
| `RemoveItem(inv, name, count, metadata, slot)`      | Remove                                                                                                   |
| `SetInventory(inv, items)`                          | Replace contents. Returns `false` and prints the item and the reason when anything could not be put back |
| `ClearInventory(inv)` / `ClearStash(inv)`           | Empty it                                                                                                 |
| `SetItemData(inv, name, key, value, slot)`          | One metadata field on the first stack of that name, or on `slot`                                         |
| `SetMetadata(inv, slot, meta)`                      | Whole metadata                                                                                           |
| `SetDurability(inv, slot, value)`                   | Condition                                                                                                |
| `SetMaxWeight(inv, grams)` / `SetSlotCount(inv, n)` | Capacity                                                                                                 |

#### Capacity checks

| Export                                               | Answers                  |
| ---------------------------------------------------- | ------------------------ |
| `CanAddItem(inv, name, count)`                       | Would this fit           |
| `CanCarryItem` · `CanCarryAmount` · `CanCarryWeight` | The carry rule, directly |

{% hint style="info" %}
Use these rather than computing capacity yourself. They call the same rule the transaction engine uses, so they cannot drift out of step with what a real move would decide.
{% endhint %}

#### Containers

| Export                                                                      | Does                                                                                         |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| `CreateInventory(id, opts)` / `RemoveInventory(id)`                         | Make / destroy                                                                               |
| `LoadInventory(src)` / `SaveInventory(src)`                                 | qb's pair: the items in qb shape / a save (every commit already saves)                       |
| `OpenInventory(src, id)` / `CloseInventory(src)`                            | Show a panel                                                                                 |
| `forceOpenInventory(src, 'stash', id)`                                      | Open a stash without standing at it; its job gate still applies. Only `'stash'` is supported |
| `RegisterStash(id, label, slots, maxWeight, owner, groups, coords, marker)` | Register a world stash                                                                       |
| `CreateDropFromPlayer(src)` / `CustomDrop(...)`                             | Ground drops                                                                                 |

#### Items in play

| Export                                                                      | Does                                                                                                                                  |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `UseItem(name, ...)`                                                        | qb-inventory's call: raises `aty_inventory:itemUsed` for that name, with no player. To use a slot as the player would, `StartConsume` |
| `RegisterUsable(name, fn)` / `UnregisterUsable(name)`                       | Custom use handler                                                                                                                    |
| `StartConsume(src, slot, opts)` · `CancelConsume(src)` · `IsConsuming(src)` | The action bar — `StartConsume` takes the same path as the player's own key press                                                     |
| `GetPortions` · `SetPortions` · `TakePortion`                               | Portions — every item is one use while `Config.Portions.enabled` is off, the default                                                  |
| `GetLoadedAmmo(inv, slot)`                                                  | The special round loaded, and rounds in a weapon                                                                                      |
| `GetOutfit(src, slot)` / `SetOutfit(src, slot, components)`                 | The outfit folded into an outfit item                                                                                                 |
| `PlaceItem(src, slot, coords, heading)`                                     | Place in the world                                                                                                                    |
| `SpawnAirdrop(coords, opts)`                                                | Call a crate                                                                                                                          |
| `Search(inv, search, items, metadata)`                                      | ox's getter — `search` is `'slots'` for the matching slots or `'count'` for a total                                                   |
| `RegisterSkillProvider(fn)`                                                 | Supply skill values                                                                                                                   |

#### Client

| Export                                                      | Returns                                                                     |
| ----------------------------------------------------------- | --------------------------------------------------------------------------- |
| `GetPlayerItems()` · `GetItemCount(name)` · `HasItem(name)` | What you carry                                                              |
| `GetPlayerWeight()` / `GetPlayerMaxWeight()`                | Grams                                                                       |
| `GetWorn()`                                                 | Worn clothing                                                               |
| `IsConsuming()`                                             | Action bar state                                                            |
| `openInventory()` / `closeInventory()`                      | The panel                                                                   |
| `Items()`                                                   | Catalogue                                                                   |
| `PlacedReport()`                                            | Placed props near you                                                       |
| `RegisterWearProvider({ apply = fn })`                      | Own the wear system: `apply` gets the worn kit and the watchdog stands down |

#### Compatibility names

Also exported under the other inventories' names, so existing code keeps working:

```
qb_AddItem  qb_RemoveItem  qb_GetInventory  qb_GetItemCount
qb_ClearInventory  qb_GetPlayerItems
```

The full `ox_inventory` surface — the entire ox server and client API, signature-for-signature — lives separately in `server/api/ox.lua` and is listed in full in Compatibility, not repeated here because it is over fifty server exports and 26 client exports long.
