# ox\_inventory

## Go to ox\_inventory/client.lua

1. Look for the following code block:

```lua
SendNUIMessage({
				action = 'setupInventory',
```

3. Add the following code directly above that SendNuiMessage function

<pre class="language-lua"><code class="lang-lua"><strong>TriggerServerEvent('rep-weed:server:checkDry', left, currentInventory)
</strong></code></pre>

<figure><img src="/files/1c7QH67uYQzRAYVyWiot" alt=""><figcaption><p>aox_inventory/client.lua</p></figcaption></figure>

#### Go to \modules\inventory\server.lua

1. Look for the following code:

```lua
function Inventory.Save(inv)
```

2. Paste the following code AFTER that whole function:

```lua
RegisterNetEvent('rep-weed:server:updateDry', function (id, slot, item)
    inv = Inventory(id)
    inv.weight -= Inventory(id).items[slot].weight
    Inventory(id).items[slot] = item
    inv.weight += Inventory(id).items[slot].weight
    inv:syncSlotsWithClients({
        {
            item = item,
            inventory = inv.id
        }
    }, true)
    if inv.player and server.syncInventory then
        server.syncInventory(inv)
    end
end)
```

<figure><img src="/files/HWfcU8Xp7aXSIpBhZcfO" alt=""><figcaption><p>ox_inventory\modules\inventory\server.lua</p></figcaption></figure>

1. Look for the following code:

```
 fromInventory.items[data.fromSlot] = fromData
```

2. Replace it with code:

```lua
if fromData then
                if fromData.name == 'wetbud' then
                    if fromInventory.type == 'stash' then
                        if fromInventory.type == 'stash' then
                            if not fromData.metadata then
                                fromData.metadata = {}
                                fromData.metadata.time = os.time()
                                fromData.metadata.dry = 10
                            else
                                if not fromData.metadata.time then fromData.metadata.time = os.time() end
                                if not fromData.metadata.dry then fromData.metadata.dry = 10 end
                            end
                        end
                    end
                end
            end
            fromInventory.items[data.fromSlot] = fromData
            if toData then
                if toData.name == 'wetbud' then
                    if toInventory.type == 'stash' then
                        print('stash')
                        if not toData.metadata then
                            toData.metadata = {}
                            toData.metadata.time = os.time()
                            toData.metadata.dry = 10
                        else
                            if not toData.metadata.time then toData.metadata.time = os.time() end
                            if not toData.metadata.dry then toData.metadata.dry = 10 end
                        end
                    end
                end
            end
            toInventory.items[data.toSlot] = toData
```

3. If you want weed to also dry in trunk, player or glove trunk, repeat the same process

***

## For `/giveitem` commands

#### Go to /server.lua

1. Look for the following code:

```lua
lib.addCommand({'additem', 'giveitem'}, {
```

3. Replace the whole function with this code.

```lua
lib.addCommand({'additem', 'giveitem'}, {
    help = 'Gives an item to a player with the given id',
    params = {
        { name = 'target', type = 'playerId', help = 'The player to receive the item' },
        { name = 'item', type = 'string', help = 'The name of the item' },
        { name = 'count', type = 'number', help = 'The amount of the item to give', optional = true },
        { name = 'type', help = 'Sets the "type" metadata to the value', optional = true },
    },
    restricted = 'group.admin',
}, function(source, args)
    local item = Items(args.item)

    if item then
        local inventory = Inventory(args.target) --[[@as OxInventory]]
        local count = args.count or 1
        local metadata = args.type and { type = tonumber(args.type) or args.type}
        if args.item == "femaleseed" then
            if not metadata then
                metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
        elseif args.item == "driedbud" then
            if not metadata then
                metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
            metadata.remainweight = 100
        elseif args.item == "weedpackage" then
            if not metadata then
                    metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
            metadata.remainweight = 100
        elseif args.item == "weedbaggie" then
            if not metadata then
                    metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
        elseif args.item == "wetbud" then
            if not metadata then
                    metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
            metadata.dry = 0
        elseif args.item == "joint" then
            if not metadata then
                    metadata = {}
            end
            metadata.strain = "Unknown"
            metadata.dry = 0
            metadata.n = 0
            metadata.p = 0
            metadata.k = 0
        elseif args.item == "wateringcan" then
            if not metadata then
                metadata = {}
            end
            metadata.water = 0
        end
        local success, response = Inventory.AddItem(inventory, item.name, count, metadata)

        if not success then
            return Citizen.Trace(('Failed to give %sx %s to player %s (%s)'):format(count, item.name, args.target, response))
        end

        source = Inventory(source) or { label = 'console', owner = 'console' }

        if server.loglevel > 0 then
            lib.logger(source.owner, 'admin', ('"%s" gave %sx %s to "%s"'):format(source.label, count, item.name, inventory.label))
        end
    end
end)
```

<figure><img src="/files/rNKv7ZySUFUfP55Z1Nmf" alt=""><figcaption><p>ox_inventory\server.lua</p></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://rep-scripts.gitbook.io/rep-scripts/paid-scripts/rep-weed/installation/qb/inventory-installation/ox_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.
