# Inventory Integration

### ✅ <mark style="color:blue;">ox\_inventory and qs-inventory already integrated with rm\_houserobbery.</mark>

## qb-inventory Integration

<mark style="color:orange;">This guide is for</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**qb-inventory**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">2.0.0. If you are using an older version of</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**qb-core**</mark><mark style="color:orange;">, the</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**AddItem**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">and</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**RemoveItem**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">functions might be located in</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**qb-core/server/player.lua**</mark> <mark style="color:orange;"></mark><mark style="color:orange;">or in any of the files within</mark> <mark style="color:orange;"></mark><mark style="color:orange;">**qb-inventory/server/**</mark><mark style="color:orange;">.</mark>

### Add Item Events to qb-inventory

To add item-related events to `qb-inventory`, follow these steps:

#### 1. Modifying the `AddItem` Function

In the file `qb-inventory/server/functions.lua`, locate the `AddItem` function. To trigger events when an item is added, insert the following code **before** the line `return true`

```lua
TriggerEvent('qb-inventory:server:itemAdded', identifier, item, amount, updated or amount)
TriggerClientEvent('qb-inventory:client:itemAdded', identifier, item, amount, updated or amount)
```

<div align="left"><figure><img src="https://3946157545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5Ce4DSFKExllozwopRT%2Fuploads%2Fwap2eU3EAPEqPPSvwpny%2Fimage.png?alt=media&#x26;token=13ae0d8c-6d93-4fb3-a098-bed8e28331f8" alt="" width="563"><figcaption></figcaption></figure></div>

#### 2. Modifying the `RemoveItem` Function

Similarly, locate the `RemoveItem` function in `qb-inventory/server/functions.lua`. Add the following lines of code **before** the `return true` statement to trigger events when an item is removed:

```lua
TriggerEvent('qb-inventory:server:itemRemoved', identifier, item, amount, inventoryItem.amount)
TriggerClientEvent('qb-inventory:client:itemRemoved', identifier, item, amount, inventoryItem.amount)
```

<div align="left"><figure><img src="https://3946157545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5Ce4DSFKExllozwopRT%2Fuploads%2FCyPhafebMaAktJ79lKfj%2Fimage.png?alt=media&#x26;token=019647ba-fa93-4103-8a13-503acf847253" alt="" width="563"><figcaption></figcaption></figure></div>

## Custom Inventory

#### Steps to Integrate Your Custom Inventory Script

1. **Assign Events to Functions:** In your custom inventory script, place the events for the `AddItem` and `RemoveItem` functions at the appropriate locations as specified.
2. **Copy and Rename the File:**
   * Navigate to the `rm_houserobbery/bridge/inventory` folder.
   * Copy one of the existing inventory script files. (like qb-inventory)
   * Rename the copied file to match the name of your custom inventory script.
3. **Update Event Names:** Open the newly created file and replace the event names with the ones you assigned in Step 1.

That’s all! You now have your custom inventory script integrate.


---

# Agent Instructions: 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.rainmad.com/resources/house-robbery-with-welding-minigame/inventory-integration.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.
