# QB-INVENTORY

## STEP \[ 1 ] — Give, throw and Place item feature

1. Open <mark style="color:yellow;">qb-inventory\server\main.lua</mark>
2. Locate this Callback <mark style="color:yellow;">`qb-inventory:server:giveItem`</mark>
3. Add the following line inside the item give logic

```lua
local itemData = GetItemByName(source, item)
if exports['sanba-realisticitemdrop']:Givethrow(source, itemData, amount) then
        cb(true)
        return
end
```

Your code should look something like this

<figure><img src="/files/WyYlv0DVIiF9seS3LiYc" alt=""><figcaption></figcaption></figure>

## STEP \[ 2 ] — Drop item feature

1. keep on  <mark style="color:yellow;">qb-inventory\server\main.lua</mark>
2. Locate this Function <mark style="color:yellow;">qb-inventory:server:createDrop</mark>
3. Add the following line inside the item drop logic

{% code overflow="wrap" %}

```lua
if exports["sanba-realisticitemdrop"]:sanbarealisticdrop(source, item) then return end
```

{% endcode %}

Your code should look something like this

<figure><img src="/files/0kllXygkBapXoWKdySPd" alt=""><figcaption></figcaption></figure>

## STEP \[ 3 ]

1. open <mark style="color:yellow;">qb-inventory\client\main.lua</mark>&#x20;
2. Locate this NUI Callback <mark style="color:yellow;">RegisterNUICallback('GiveItem', function(data, cb)</mark>
3. Replace all the nui callback with the following

{% code overflow="wrap" %}

```lua
RegisterNUICallback('GiveItem', function(data, cb)
    local player, distance = QBCore.Functions.GetClosestPlayer(GetEntityCoords(PlayerPedId()))
    local targetId = (player ~= -1 and distance < 3) and GetPlayerServerId(player) or nil

    QBCore.Functions.TriggerCallback('qb-inventory:server:giveItem', function(success)
        cb(success)
    end, targetId, data.item.name, data.amount, data.slot, data.info)
end)
```

{% endcode %}

Your code should look something like this

<figure><img src="/files/BwPW8dbNxmHTQs61oHv1" alt=""><figcaption></figcaption></figure>


---

# 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://sanbascripts.gitbook.io/bytestake/realistic-item-drop/installation/qb-inventory.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.
