> For the complete documentation index, see [llms.txt](https://docs.av-scripts.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.av-scripts.com/laptop-pack/laptop/installation/inventories/qb-inventory/version-1.x.md).

# Version 1.x

> This is for qb-inventory version 1.x, you can verify it in the fxmanifest.lua

* Go to `av_laptop/config/_inventory.lua` and set

```lua
Config.OldQBInventory = true
```

* Go to `qb-inventory/fxmanifest.lua` and delete any `server_script` line you might have and replace it with:

```lua
server_scripts {
    '@oxmysql/lib/MySQL.lua',
    'server/*.lua',
}
```

* Place the following file in `qb-inventory/server/` folder:

{% file src="/files/lkspoBtwR3MeFww7Ruu9" %}

* The following edits should be made in `qb-inventory/server/main.lua`&#x20;
* Search the event **inventory:server:SetInventoryData,** inside this event you should have a line pretty similar to this:

```lua
if (fromInventory == "player" or fromInventory == "hotbar") and (QBCore.Shared.SplitStr(toInventory, "-")[1] == "itemshop" or toInventory == "crafting") then
		return
end
```

* Replace that line with the following:

```lua
if isRestricted(toInventory) then return end
```

* Search the function **SetItemData** and replace it with:

<pre class="language-lua"><code class="lang-lua"><strong>local function SetItemData(source, itemName, key, val, slot)
</strong>	if not itemName or not key then return false end

	local Player = QBCore.Functions.GetPlayer(source)

	if not Player then return end
	local item = nil
	if slot then
		item = Player.PlayerData.items[slot]
	else
		item = GetItemByName(source, itemName)
	end
	if not item then return false end

	item[key] = val
	Player.PlayerData.items[item.slot] = item
	Player.Functions.SetPlayerData("items", Player.PlayerData.items)
	return true
end
</code></pre>

* Replace the function **AddToStash**:

```lua
local function AddToStash(stashId, slot, otherslot, itemName, amount, info)
    local slot = slot or 1
    amount = tonumber(amount) or 1
    local ItemData = SharedItems(itemName)
    if not ItemData then
        print("Item "..itemName.." doesn't exist")
        return
    end
    Stashes[stashId] = Stashes[stashId] or {}
    Stashes[stashId]['items'] = Stashes[stashId]['items'] or {}
    Stashes[stashId].items[slot] = Stashes[stashId].items[slot] or {}
    
    if not ItemData.unique then
        if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
            Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount + amount
        else
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[slot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = slot,
            }
        end
    else
        if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[otherslot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = otherslot,
            }
        else
            local itemInfo = SharedItems(itemName:lower())
            Stashes[stashId].items[slot] = {
                name = itemInfo['name'],
                amount = amount,
                info = info or '',
                label = itemInfo['label'],
                description = itemInfo['description'] or '',
                weight = itemInfo['weight'],
                type = itemInfo['type'],
                unique = itemInfo['unique'],
                useable = itemInfo['useable'],
                image = itemInfo['image'],
                slot = slot,
            }
        end
    end
end
```

* Search the function **addTrunkItems** and replace it with:

```lua
function addTrunkItems(plate, items) -- av-scripts
	Trunks[plate] = {}
	Trunks[plate].label = "Trunk-"..plate
	Trunks[plate].items = items
end
```

* Search for the event **inventory:server:SaveInventory** and replace it with:

```lua
RegisterNetEvent('inventory:server:SaveInventory', function(type, id) -- av-scripts
	local src = source
	if type == 'trunk' then
		if IsVehicleOwned(id) then
			SaveOwnedVehicleItems(id, Trunks[id].items)
		else
			Trunks[id].isOpen = false
		end
	elseif type == 'glovebox' then
		if (IsVehicleOwned(id)) then
			SaveOwnedGloveboxItems(id, Gloveboxes[id].items)
		else
			Gloveboxes[id].isOpen = false
		end
	elseif type == 'stash' then
		SaveStashItems(id, Stashes[id].items)
	elseif type == 'drop' then
		if Drops[id] then
			Drops[id].isOpen = false
			if Drops[id].items == nil or next(Drops[id].items) == nil then
				Drops[id] = nil
				TriggerClientEvent('inventory:client:RemoveDropItem', -1, id)
			end
		end
	end
	TriggerEvent("av_scripts:inventorySaved",src,type,id)
end)
```

* Search for the event **inventory:server:OpenInventory** and do the following:
  * Add the parameter **newLabel** inside the function()
  * Replace `secondInv.label = 'Stash-'..id` with the following:

```lua
secondInv.label = newLabel or 'Stash-' .. id
```

* Should look *something* like this:

```lua
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other, newLabel) -- ADD IT HERE
	local src = source
	local ply = Player(src)
	local Player = QBCore.Functions.GetPlayer(src)
	if ply.state.inv_busy then
		return QBCore.Functions.Notify(src, Lang:t('notify.noaccess'), 'error')
	end
	if name and id then
		local secondInv = {}
		if name == 'stash' then
			if Stashes[id] then
				if Stashes[id].isOpen then
					local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
					if Target then
						TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
					else
						Stashes[id].isOpen = false
					end
				end
			end
			local maxweight = 1000000
			local slots = 50
			if other then
				maxweight = other.maxweight or 1000000
				slots = other.slots or 50
			end
			secondInv.name = 'stash-' .. id
			secondInv.label = newLabel or 'Stash-' .. id -- REPLACE HERE
			
-- There's more code than this in your inventory
-- So please DON'T copy/paste any of this code to your inventory, just add the needed lines
```

* Copy/paste this code at the end of the file:

```lua
-- av-scripts export:
function WipeStash(id) -- for old qb-inventory
	Stashes[id] = {}
	Stashes[id].items = {}
	SaveStashItems(id, Stashes[id].items)
end

exports('addStashItem', AddToStash)
exports('addTrunkItems', addTrunkItems)
exports("GetStashItems", GetStashItems)
exports("SaveStashItems",SaveStashItems)
exports('RemoveFromStash', RemoveFromStash)
exports("WipeStash", WipeStash)
```
