> For the complete documentation index, see [llms.txt](https://brunx-mods.gitbook.io/brunx-mods-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brunx-mods.gitbook.io/brunx-mods-docs/products/scripts/cinema-system/inventories/server-guide.md).

# Server guide

Make sure to check the qb-inventory.lua and ox\_inventory.lua files for examples on how to implement the script for your framework. They are always up to date with the latest changes.

Make sure to check the qb-inventory.lua and ox\_inventory.lua files for examples on how to implement the script for your framework. They are always up to date with the latest changes.

## Inventory functions

### canAddItem

***

Function to check whether it is possible to add the item to the inventory

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param item: string
-- @param amount: number
canAddItem = function(source, item, amount)
    return exports['qb-inventory']:CanAddItem(source, item, amount)
end
```

### addItem

***

Function to add item to inventory

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param item: string
-- @param amount: number
addItem = function(source, item, amount)
    exports['qb-inventory']:AddItem(source, item, amount)
end
```

### removeItem

***

Remove item function

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param item: string
-- @param amount: number
removeItem = function(source, item, amount)
	return exports['qb-inventory']:RemoveItem(source, item, amount)
end
```

### getItemAmount

***

function to get the quantity of the item in the inventory

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param item: string
getItemAmount = function(source, item)
    local Player <const> = QB.Functions.GetPlayer(source)
    local invItem <const> = Player.Functions.GetItemByName(item)
    return invItem?.amount or 0
end
```

### getItemMeta

***

Function to get the item's metadata

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param data: table (room:string | schedule:string)
getItemMeta = function(source, data)
    local cb = false

    local Player <const> = QB.Functions.GetPlayer(source)
    local Items <const> = Player.PlayerData.items
    for i = 1, #Items do
        local item <const> = Items[i]

        if (item and item.name == config.item.spawn) and (item.info.room and item.info.room == data.room) and (item.info.schedule == data.schedule) then
            cb = { room = item.info.room, date = item.info.date, schedule = item.info.schedule }
            break;
        end
    end
    return cb
end
```

### setItemMeta

***

Function to set the item's metadata.

```lua
-- This is an example from the brnx-iceorinksystem qb.lua file

-- @param source: number
-- @param data: table (room:string | schedule:string | date:number)
setItemMeta = function(source, data)
    local Player <const> = QB.Functions.GetPlayer(source)
    local Items <const> = Player.PlayerData.items
    for i = 1, #Items do
        local item <const> = Items[i]

        if (item) and item.name == config.item.spawn and not item.info.room then
            item.info.room = data.room
            item.info.schedule = data.schedule
            item.info.date = data.date
            
            Player.Functions.SetInventory(Items, true)
            break;
        end
    end
end
```
