> For the complete documentation index, see [llms.txt](https://devix.gitbook.io/devix/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://devix.gitbook.io/devix/devix-inventory/installation/qbox_core/ox_inventory.md).

# ox\_inventory

#### ox\_inventory API with devix-inventory

This project exposes the **ox\_inventory API** while using **devix-inventory** as the backend.\
This document explains how to migrate existing ox\_inventory setups and how to define item usage.

***

#### 1. Quick migration from ox\_inventory/items.lua

If you already have an `items.lua` from ox\_inventory, you can import it directly into devix-inventory.

{% stepper %}
{% step %}

### Place your existing items.lua

Put your ox-style `items.lua` into the `import_items` folder inside devix-inventory:

```
[devix]/devix-inventory/import_items/items.lua
```

{% endstep %}

{% step %}

### Run the import command

In the server console (or as an admin in-game), run:

```
/importitems
```

The importer will:

* Read `import_items/items.lua`.
* Convert ox\_inventory items into devix format.
* Write all entries into `devix-inventory/config_items.lua`.

After this step:

* Your items exist in devix-inventory’s **Config.ItemList**.
* Labels, weights, images, etc. are populated from your original ox\_inventory definitions.

You only need to keep `items.lua` in `import_items` for import; after `/importitems` the master copy is `config_items.lua`.
{% endstep %}
{% endstepper %}

***

#### 2. fxmanifest configuration (provide)

devix-inventory already exposes the ox\_inventory API via its integration layer.

* In **devix-inventory/fxmanifest.lua**, there is a `provide 'ox_inventory'` line.
* If you have other resources that also declare `provide 'ox_inventory'`, **disable those** and keep **only the devix-inventory provide active**.

Result:

* Other scripts can keep using `exports.ox_inventory:*` as before.
* The actual inventory backend is devix-inventory, not the original ox\_inventory resource.

***

#### 3. Devix-core framework configuration

devix-core controls which framework integration is active (QBX, qb-core, ESX, ox, etc.).

Open `[devix]/devix-core/shared/config.lua` and set:

```lua
-- Example for QBX / qbox
Config.FrameworkOverride = "qbox"
```

Supported values include (but are not limited to):

* `"qbox"` (QBX / qbx\_core)
* `"qb"` or `"oldqb"` (qb-core / legacy)
* `"esx"` or `"oldesx"` (es\_extended / legacy)

Make sure this matches the framework you are actually running.\
devix-core uses this to:

* Resolve player objects and identifiers.
* Bridge usable items (`DEVIX.CanUseItem`, `DEVIX.CallUsableItem`).
* Integrate framework money with devix-inventory when configured.

***

#### 4. Where item data vs. item usage live

There are two main concepts:

* Item data (exists in inventory, shows in UI)
  * Defined in `devix-inventory/config_items.lua` (`Config.ItemList`).
  * Contains: `name`, `label`, `weight`, `type`, `image`, `unique`, `useable`, `shouldClose`, `itemLimit`, `description`, etc.
  * `/importitems` writes into this file.
* Item usage (what happens when you click "Use")
  * Can be defined in **devix-inventory** via `client` / `server` blocks in `config_items.lua`:

    ```lua
        ['item_name'] = {
            label       = 'Item Label',
            weight      = 100,
            stack       = true,
            close       = true,
            description = '...',
            -- Usage (optional)
            client = {
                event  = 'your_script:client:useItem', -- client event
                -- or
                export = 'your_script.useItem',        -- client export "resource.function"
            },
            server = {
                export = 'your_script.useItem',        -- server export "resource.function"
            },
        },
    -- Example :: 
        ['phone'] = {
                name        = 'phone',
                label       = 'Phone',
                weight      = 190,
                type        = 'item',
                image       = 'phone.png',
                unique      = true,
                useable     = true,
                shouldClose = true,
                itemLimit   = 1,
                description = 'Phone.',
                client = {
                    use = {
                        event = 'devix-inventory:client:autoItemUse',
                        action = function(itemData, slot)
                            print('use', itemData, slot)
                            -- NPWD: enable + open phone UI
                            pcall(function()
                                exports.npwd:setPhoneDisabled(false)
                                exports.npwd:setPhoneVisible(true)
                            end)
                            -- qbx_npwd compatibility (in case it wraps extra logic)
                            TriggerEvent('qbx_npwd:client:setPhoneVisible', true)
                        end,
                    },
                    add = {
                        event = 'devix-inventory:client:autoItemAdd',
                        action = function(total, itemName)
                            TriggerEvent('devix-inventory:client:autoItemAdd', itemName or 'phone', tonumber(total) or 0)
                        end,
                    },
                    remove = {
                        event = 'devix-inventory:client:autoItemRemove',
                        action = function(total, itemName)
                            TriggerEvent('devix-inventory:client:autoItemRemove', itemName or 'phone', tonumber(total) or 0)
                        end,
                    },
                },
            },
    ```
  * Or via framework usables (QBX / qb-core / ESX) using `DEVIX.UsableItem` / `CreateUseableItem`.

For most migrations:

1. Use `/importitems` to populate `config_items.lua` with item data.
2. Add or adjust `client.use` / `server.useExport` for items that need custom behaviour.

***

#### 5. Using the ox\_inventory API with devix-inventory

Once devix-inventory is installed and `provide` is set correctly, you can call ox\_inventory-style functions as usual from other resources:

```lua
-- Server: give item to a player
exports.ox_inventory:AddItem(source, 'phone', 1)

-- Server: remove item
exports.ox_inventory:RemoveItem(source, 'phone', 1)

-- Server: get count
local count = exports.ox_inventory:GetItemCount(source, 'phone')

-- Client: use item for local player
exports.ox_inventory:AddItem('phone', 1)  -- devix bridge routes this to server
```

Under the hood:

* These calls are routed through `devix-inventory/server/integration/ox_inventory/init.lua`.
* The bridge resolves the player source and calls devix-inventory’s internal `AddItem`, `RemoveItem`, `GetItemCount`, etc.

***

#### 6. Recommended start order

For a stable setup:

1. `ensure devix-core`
2. `ensure devix-inventory`
3. Start all your other resources that expect ox\_inventory (they will see the API exported by devix-inventory).

This guarantees:

* devix-core is ready before devix-inventory.
* devix-inventory is ready before any external resource starts calling `exports.ox_inventory:*`.

***

#### 7. Summary

* Place your old ox\_inventory `items.lua` into `devix-inventory/import_items/` and run `/importitems` to generate `config_items.lua`.
* Keep only the devix-inventory `provide 'ox_inventory'` active so there is a single ox\_inventory API provider.
* Set `Config.FrameworkOverride` in devix-core to match your framework (e.g. `"qbox"` for QBX).
* Use `config_items.lua` for **item data**, and devix’s `client` / `server` callbacks (or framework usables) for **usage behaviour**.
* From other scripts, continue calling `exports.ox_inventory:*`; devix-inventory will handle the underlying storage and behaviour.


---

# 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, and the optional `goal` query parameter:

```
GET https://devix.gitbook.io/devix/devix-inventory/installation/qbox_core/ox_inventory.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
