> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vorp-core.com/llms.txt
> Use this file to discover all available pages before exploring further.

# inventory

> Documentation for vorp inventory system

> [!WARNING]
>
> This documentation is for developers who are making scripts for VORP Core Framework

## Exports

***

> [!NOTE]
>
> These exports are client side only!

> [tab] Items
>
> ### Getters
>
> > [accordion] getInventoryItems
> >
> > &#x20;get all user inventory items
> >
> > **return** `table`
> >
> > `returns` a table containing all the items in the inventory
> >
> > ```lua theme={null}
> > local result = exports.vorp_inventory:getInventoryItems()
> > ```
>
> > [accordion] getInventoryItem
> >
> > &#x20;get user inventory item
> >
> > **string** `name`
> >
> > the item name
> >
> > **return** `table`
> >
> > `returns` a table containing the item name,label,weight,desc metadata, percentage
> >
> > ```lua theme={null}
> > local result = exports.vorp_inventory:getInventoryItem()
> > ```
>
> > [accordion] getServerItem
> >
> > **datae** `string|table`
> >
> > the item name to get or an table of items to get in one single call, returns the data from items database like label,weight,desc,metadata etc
> >
> > ```lua theme={null}
> > local result = exports.vorp_inventory:getServerItem("water")
> > print(result.label)
> > ```

> [tab] Inventory
>
> > [accordion] closeInventory
> >
> > &#x20;close inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:closeInventory()
> > ```

> [!NOTE]
>
> These exports are server side only!

> [tab] Weapons
>
> ### Getters
>
> > [accordion] getUserAmmo
> >
> > &#x20;get all user ammo
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `returns` a table containing all the ammo
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getUserAmmo(source, callback)
> > ```
>
> > [accordion] canCarryWeapons
> >
> > &#x20;check if player can carry weapons
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **amount** `int` *required*
> >
> > amount of weapons
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **weaponName** `string | number`
> >
> > weapon name or hash its needed to check weight since 3.6
> >
> > **return** `boolean`
> >
> > `returns` true if the player can carry the weapons
> >
> > ```lua theme={null}
> > exports.vorp_inventory:canCarryWeapons(source, amount,callback, weaponName)
> > ```
>
> > [accordion] getUserWeapon
> >
> > &#x20;get user inventory weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **weaponId** `number`
> >
> > weapon id
> >
> > **return** `table`
> >
> > `{id:number,name:string,propietary:string,used:boolean,desc:string,group:number,source:number,label:string,serial_number:string,custom_label:string,custom_desc:string}`
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getUserWeapon(source, callback,weaponId)
> > ```
>
> > [accordion] getUserInventoryWeapons
> >
> > &#x20;get user inventory weapons
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `{id:number,name:string,propietary:string,used:boolean,desc:string,group:number,source:number,label:string,serial_number:string,custom_label:string,custom_desc:string}`
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getUserInventoryWeapons(source, callback)
> > ```
>
> > [accordion] getWeaponBullets
> >
> > &#x20;get weapon bullets
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponID** `number` *required*
> >
> > weapon id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `number`
> >
> > weapon ammo
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getWeaponBullets(source,weaponID, callback)
> > ```
>
> > [accordion] getWeaponComponents
> >
> > &#x20;get weapon components
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `returns` a table containing the weapon components
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getWeaponComponents(source, weaponId, callback)
> > ```
>
> ### Setters
>
> > [accordion] setWeaponCustomDesc
> >
> > &#x20;set weapon custom description
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **desc** `string` *required*
> >
> > weapon description
> >
> > **cb** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the description was successfully set
> >
> > ```lua theme={null}
> > exports.vorp_inventory:setWeaponCustomDesc(weaponId, desc, cb)
> > ```
>
> > [accordion] setWeaponCustomLabel
> >
> > &#x20;set weapon custom label
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **label** `string` *required*
> >
> > weapon label
> >
> > **cb** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns`true if the label was successfully set
> >
> > ```lua theme={null}
> > exports.vorp_inventory:setWeaponCustomLabel(weaponId, label, cb)
> > ```
>
> > [accordion] setWeaponSerialNumber
> >
> > &#x20;set weapon serial number
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **serial** `string` *required*
> >
> > weapon serial number
> >
> > **cb** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the serial number was successfully set
> >
> > ```lua theme={null}
> > exports.vorp_inventory:setWeaponSerialNumber(weaponId, serial, cb)
> > ```
>
> > [accordion] subWeapon
> >
> > &#x20;remove weapon from user inventory
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the weapon was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subWeapon(source, weaponId, callback)
> > ```
>
> > [accordion] giveWeapon
> >
> > &#x20;give weapon to user
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **target** `int` *required*
> >
> > target id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the weapon was successfully given
> >
> > ```lua theme={null}
> > exports.vorp_inventory:giveWeapon(source, weaponId, target,callback)
> > ```
>
> > [accordion] createWeapon
> >
> > &#x20;create weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponName** `string` *required*
> >
> > weapon name
> >
> > **ammo** `string` *required*
> >
> > amount of ammo
> >
> > **components** `table` *required*
> >
> > weapon components
> >
> > **comps** `table` *required*
> >
> > weapon components
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **wepid** `int`
> >
> > leave this as nil, this is used internally only
> >
> > **serial** `string`
> >
> > custom serial number for weapon
> >
> > **label** `string`
> >
> > custom label for weapon
> >
> > **desc** `string`
> >
> > custom desc for weapons
> >
> > **return** `boolean`
> >
> > if async
> >
> > ```lua theme={null}
> > exports.vorp_inventory:createWeapon(source, weaponName, ammo, components, comps, callback,serial,label,desc)
> > ```
>
> > [accordion] deleteWeapon
> >
> > &#x20;delete weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > if async
> >
> > ```lua theme={null}
> > exports.vorp_inventory:deleteWeapon(source, weaponId, callback)
> > ```
>
> > [accordion] addBullets
> >
> > &#x20;add bullets
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **bulletType** `string` *required*
> >
> > bullet type
> >
> > **amount** `number` *required*
> >
> > amount of bullets
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the bullets were successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addBullets(source, bulletType, amount,callback)
> > ```
>
> > [accordion] subBullets
> >
> > &#x20;remove bullets from weapon
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **bulletType** `string` *required*
> >
> > bullet type
> >
> > **amount** `number` *required*
> >
> > amount of bullets
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the bullets were successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subBullets(weaponId, bulletType, amount,callback)
> > ```
>
> > [accordion] removeAllUserAmmo
> >
> > &#x20;remove all user ammo
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > ```lua theme={null}
> > exports.vorp_inventory:removeAllUserAmmo(source)
> > ```
>
> > [accordion] addWeaponComponent
> >
> > &#x20;add a component to a weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **component** `string | number` *required*
> >
> > component name or hash
> >
> > **category** `string | number` *required*
> >
> > slot category
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the component was successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addWeaponComponent(source, weaponId, component, category, callback)
> > ```
>
> > [accordion] addWeaponComponents
> >
> > &#x20;add multiple components to a weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **components** `table` *required*
> >
> > a table where the key is the component name or hash and the value is the slot category `{ [component] = category }`
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the components were successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addWeaponComponents(source, weaponId, components, callback)
> > ```
>
> > [accordion] subWeaponComponent
> >
> > &#x20;remove a component from a weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **component** `string | number` *required*
> >
> > component name or hash
> >
> > **category** `string | number` *required*
> >
> > slot category
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the component was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subWeaponComponent(source, weaponId, component, category, callback)
> > ```
>
> > [accordion] subWeaponComponents
> >
> > &#x20;remove multiple components from a weapon
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **weaponId** `number` *required*
> >
> > weapon id
> >
> > **components** `table` *required*
> >
> > a table where the key is the component name or hash and the value is the slot category `{ [component] = category }`
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the components were successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subWeaponComponents(source, weaponId, components, callback)
> > ```

> [tab] Items
>
> ### Getters
>
> > [accordion] canCarryItem
> >
> > &#x20;check if player can carry the item before adding it to the inventory
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **item** `string` *required*
> >
> > The item name
> >
> > **amount** `int` *required*
> >
> > The amount of items
> >
> > **callback** `function`
> >
> > The callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the player can carry the item
> >
> > ```lua theme={null}
> > exports.vorp_inventory:canCarryItem(source, item, amount, callback)
> > ```
>
> > [accordion] getUserInventoryItems
> >
> > &#x20;gets all the items in the player inventory
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **callback** `function`
> >
> > The callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `returns` a table containing all the items in the inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getUserInventoryItems(source, callback)
> > ```
>
> > [accordion] getItemCount
> >
> > &#x20;get item amount from player inventory
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **callback** `function`
> >
> > callback function for syncronous or asyncronous
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **metadata** `table`
> >
> > item metadata
> >
> > **percentage** `int`
> >
> > allows to control what items to get, if 0 gets all items with no metadata if meta was not passed if 0 gets items expired, anything above 0 or equal will return those item count
> >
> > **return** `int`
> >
> > `returns` the amount of items in the inventory
> >
> > ```lua usage theme={null}
> > exports.vorp_inventory:getItemCount(source, callback, item, metadata, percentage)
> > ```
>
> > [accordion] getItemDB
> >
> > &#x20;get DB item
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **callback** `function`
> >
> > callback function asyncronous or syncronous
> >
> > **return** `table`
> >
> > `returns` a table containing item info
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getItemDB(item, callback)
> > ```
>
> > [accordion] getItemById
> >
> > &#x20;get item by main id
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **id** `int` *required*
> >
> > item id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `{id:number, label:string, name:string, metadata:table, group:number, type:string, count:number, limit:number,canUse:boolean,percenage:integer,description:string,weight:number}`
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getItemById(source, id, callback)
> > ```
>
> > [accordion] getItem
> >
> > &#x20;get item data
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **metadata** `table`
> >
> > item metadata
> >
> > **percentage** `int`
> >
> > get an item only at a certain percentage, if 0 it gets tems expired if nil gets any item if more than 0 gets any item that equals or is above
> >
> > **return** `table`
> >
> > `{id:number, label:string, name:string, metadata:table, group:number, type:string, count:number, limit:number,canUse:boolean,weight:number,desc:string,percentage:integer}`
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getItem(source, item,callback, metadata,percentage)
> > ```
>
> ### Setters
>
> > [accordion] addItem
> >
> > &#x20;add item to user
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **amount** `int` *required*
> >
> > amount of item
> >
> > **metadata** `table`
> >
> > item metadata
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **event** `boolean`
> >
> > if true will not trigger the event OnItemCreated
> >
> > **return** `boolean`
> >
> > `returns` true if the item was successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addItem(source, item, amount, metadata, callback,event)
> > ```
>
> > [accordion] subItem
> >
> > &#x20;remove item from user inventory
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **amount** `int` *required*
> >
> > amount of item
> >
> > **metadata** `table`
> >
> > item metadata
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **event** `boolean`
> >
> > event OnItemRemoved to be fired, if true it wont be sent, false or nil it will fire the event
> >
> > **percentage** `int`
> >
> > allows to control percentage of items to remove, if nil removes any, if 0 removes expired items only, if more than 0 it removes anything above or equal
> >
> > **return** `boolean`
> >
> > `returns` true if the item was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subItem(source, item, amount, metadata, callback,event,percentage)
> > ```
>
> > [accordion] subItemById
> >
> > &#x20;remove item from user inventory by its id exort available on verion 3.9 and up lower versions uses subItemID
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **itemId** `int` *required*
> >
> > item id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **event** `boolean`
> >
> > event OnItemRemoved to be fired, if true it wont be sent, false or nil it will fire the event
> >
> > **amount** `int`
> >
> > amount to remove
> >
> > **return** `boolean`
> >
> > `returns` true if the item was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:subItemById(source, itemId,callback,event,amount)
> > ```
>
> > [accordion] setItemMetadata
> >
> > * Split a stack and modify only some items (amount must be less than the current stack)
> > * Merge with an existing stack that has matching metadata (amount must be more or equal than the current stack)
> > * Modify the entire stack's metadata (amount must be more or equal than the current stack) this only applies if metadata is the same as current stack
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **itemId** `int` *required*
> >
> > item id
> >
> > **metadata** `table`
> >
> > reserved keys are:
> >
> > * `description` the description of the item to replace
> > * `image` the image of the item to replace must exist in item folder.
> > * `label` the label of the item to replace
> > * `weight` the weight of the item to replace
> > * `tolltip` add extra text to the tooltip
> > * `context` add context buttons to the item
> > * `useExpired` if true allows to use expired items overriding the useExpired setting in the item db
> >
> > **amount** `int` *required*
> >
> > amount of item to remove from current stack if less, if more it will remove from here and add to another stack if metadata matches, if not then it updates the entire stack with new meta
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the metadata was successfully set
> >
> > ```lua theme={null}
> > -- FOR CONTEXT BUTTONS USE THIS FORMAT
> > local metadata = {
> >   context = { -- key word for context buttons
> >     { -- array supporting multiple buttons
> >           text = "BUTTON", -- label shown in menu
> >           close = true, -- close inv on use
> >           event = {
> >               client = "myscript:contextevent", -- client event to trigger
> >               server = "myscript:contextevent" -- server event to trigger
> >           },
> >           arguments = { -- arguments to pass to the event if needed
> >               "any",
> >           }
> >       }
> >   }
> > }
> >
> > -- listen in your scripts client side
> > AddEventHandler("myscript:contextevent", function(args,itemId)
> >
> > end) 
> >
> > -- NOTE: for server side events you must whitelist the event using the exports bellow
> > exports.vorp_inventory:addAllowedContextMenuEvent("myscript:contextevent",GetCurrentResourceName())
> > -- or as a table
> > exports.vorp_inventory:addAllowedContextMenuEvent({
> >   "myscript:contextevent",
> >   "myscript:contextevent2"
> > },GetCurrentResourceName())
> > -- if you dont whitelist the event it will not be triggered this is to ensure only trusted events are triggered
> >
> > -- to remove a whitelisted event
> > exports.vorp_inventory:removeAllowedContextMenuEvent("myscript:contextevent",GetCurrentResourceName())
> > -- or as a table
> > exports.vorp_inventory:removeAllowedContextMenuEvents({
> >   "myscript:contextevent",
> >   "myscript:contextevent2"
> > },GetCurrentResourceName())
> >
> > -- server side of your script
> > AddEventHandler("myscript:contextevent", function(source,args,itemId)
> >
> > end)
> > ```
> >
> > ```lua theme={null}
> >   -- SET ITEM METADATA
> >   exports.vorp_inventory:setItemMetadata(source, itemId, metadata, amount, callback)
> > ```
>
> > [accordion] registerUsableItem
> >
> > &#x20;register usable item
> > \[!NOTE] Items cant be registered twice they must be unique
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **callback** `function` *required*
> >
> > callback `{source:int, id:number, label:string, name:string, metadata:table, group:number, type:string, count:number, limit:number,canUse:boolean, mainid: integer, percentage:integer}`
> >
> > **resourceName** `string`
> >
> > resource name for debug purposes so users can see in what resource this item is registered at
> >
> > ```lua theme={null}
> > exports.vorp_inventory:registerUsableItem(item, callback,resourceName)
> > ```
>
> > [accordion] unRegisterUsableItem
> >
> > &#x20;un register usable item when you stop a script for example
> > \[!NOTE] Items cant be registered twice they must be unique
> >
> > **item** `string` *required*
> >
> > item name
> >
> > ```lua theme={null}
> > exports.vorp_inventory:unRegisterUsableItem(item)
> > ```

> [tab] Inventory items
>
> ### Getters
>
> > [accordion] getCustomInventoryItemCount
> >
> > &#x20;get custom inventory item count
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **itemName** `string` *required*
> >
> > item name
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **metadata** `table`
> >
> > if metadata is provided then it will return the amount of items with the same metadata
> >
> > **return** `number`
> >
> > `returns` the amount of items in the inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getCustomInventoryItemCount(invid,itemName,callback,metadata)
> > ```
>
> > [accordion] getCustomInventoryItems
> >
> > &#x20;get custom inventory items
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `returns` a table containing all the items in the inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getCustomInventoryItems(invid, callback)
> > ```
>
> ### Setters
>
> > [accordion] removeItemFromCustomInventory
> >
> > &#x20;remove item from custom inventory
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **itemName** `string` *required*
> >
> > item name
> >
> > **amount** `number` *required*
> >
> > amount of item
> >
> > **itemCraftedId** `number` *required*
> >
> > item crafted id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the item was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:removeItemFromCustomInventory(invid,itemName,callback)
> > ```
>
> > [accordion] updateCustomInventoryItem
> >
> > &#x20;update item in custom inventory
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **item\_id** `number` *required*
> >
> > item id
> >
> > **metadata** `table` *required*
> >
> > metadata to update
> >
> > **amount** `number`
> >
> > amount of item
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the item was successfully updated
> >
> > ```lua theme={null}
> > exports.vorp_inventory:updateCustomInventoryItem(invId, item_id, metadata, amount, callback)
> > ```
>
> > [accordion] addItemsToCustomInventory
> >
> > &#x20;add items to custom inventory
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **items** `table` *required*
> >
> > items to add
> >
> > **charid** `number`
> >
> > charidentifier of the owner of the storage if custom inv is not shared , if its shared can be any characteridentifer
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the items were successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addItemsToCustomInventory(invid, items, charid,callback)
> > ```
>
> > [accordion] setCustomInventoryItemLimit
> >
> > &#x20;if in registerCustomInventory you set whitelistItems true then use this export to set which items are whitelisted and their amount
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **item** `string` *required*
> >
> > item name
> >
> > **limit** `number` *required*
> >
> > item limit
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the limit was successfully set
> >
> > ```lua theme={null}
> > exports.vorp_inventory:setCustomInventoryItemLimit(invId, item, limit, callback)
> > ```

> [tab] Inventory weapons
>
> ### Getters
>
> > [accordion] getCustomInventoryWeapons
> >
> > &#x20;get custom inventory weapons
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `table`
> >
> > `returns` a table containing all the weapons in the inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getCustomInventoryWeapons(invid, callback)
> > ```
>
> > [accordion] getCustomInventoryWeaponCount
> >
> > &#x20;get custom inventory weapon count
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **weaponName** `string` *required*
> >
> > weapon name
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `number`
> >
> > `returns` the amount of weapons in the inventory
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getCustomInventoryWeaponCount(invid,weaponName,callback)
> > ```
>
> ### Setter
>
> > [accordion] removeCustomInventoryWeaponById
> >
> > &#x20;remove weapon from custom inventory by weapon id
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **weapon\_id** `number` *required*
> >
> > weapon id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the weapon was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:removeCustomInventoryWeaponById(invId, weapon_id, callback)
> > ```
>
> > [accordion] removeWeaponFromCustomInventory
> >
> > &#x20;remove weapon from custom inventory
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **weaponName** `string` *required*
> >
> > weapon name
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the weapon was successfully removed
> >
> > ```lua theme={null}
> > exports.vorp_inventory:removeWeaponFromCustomInventory(invid,weaponName,callback)
> > ```
>
> > [accordion] addWeaponsToCustomInventory
> >
> > &#x20;add weapons to custom inventory
> >
> > **invid** `string` *required*
> >
> > inventory id
> >
> > **weapons** `table` *required*
> >
> > `{name: string, serial_number: string?, custom_label: string?, custom_desc: string?, components: table?}`
> >
> > **charid** `number`
> >
> > charidentifier of the owner of the storage if custom inv is not shared , if its shared can be any characteridentifer
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the weapons were successfully added
> >
> > ```lua theme={null}
> > exports.vorp_inventory:addWeaponsToCustomInventory(invid, weapons, charid,callback)
> > ```
>
> > [accordion] setCustomInventoryWeaponLimit
> >
> > &#x20;set custom inventory whitelisted weapons, if in registerCustomInventory you set whitelistWeapons true then use this export to set which weapons are whitelisted and their amount
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **weapon** `string` *required*
> >
> > weapon name
> >
> > **limit** `number` *required*
> >
> > weapon limit
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the limit was successfully set
> >
> > ```lua theme={null}
> > exports.vorp_inventory:setCustomInventoryWeaponLimit(invId, weapon, limit, callback)
> > ```

> [tab] Inventory misc
>
> ### Getters
>
> > [accordion] isCustomInventoryRegistered
> >
> > &#x20;check if inventory is registered
> >
> > **id** `string` *required*
> >
> > inventory id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > **return** `boolean`
> >
> > `returns` true if the inventory is registered
> >
> > ```lua theme={null}
> > exports.vorp_inventory:isCustomInventoryRegistered(id, callback)
> > ```
>
> > [accordion] AddCharIdPermissionTakeFromCustom
> >
> > &#x20;add permissions using charids
> >
> > **id** `string` *required*
> >
> > inventory id
> >
> > **charid** `number` *required*
> >
> > charid
> >
> > **state** `boolean`
> >
> > state
> >
> > ```lua theme={null}
> > exports.vorp_inventory:AddCharIdPermissionTakeFromCustom(id,charid,state)
> > ```
>
> > [accordion] AddCharIdPermissionMoveToCustom
> >
> > &#x20;add permissions using charids
> >
> > **id** `string` *required*
> >
> > inventory id
> >
> > **charid** `number` *required*
> >
> > charid
> >
> > **state** `boolean`
> >
> > state
> >
> > ```lua theme={null}
> > exports.vorp_inventory:AddCharIdPermissionMoveToCustom(id,charid,state)
> > ```
>
> > [accordion] getCustomInventorySlots
> >
> > &#x20;get cached inventory slots
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **callback** `function`
> >
> > callback function syncronous or asyncronous
> >
> > ```lua theme={null}
> > exports.vorp_inventory:getCustomInventorySlots(invId,callback)
> > ```
>
> ### Setters
>
> > [accordion] deleteCustomInventory
> >
> > &#x20;delete custom inventory from data base and cache
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > ```lua theme={null}
> > exports.vorp_inventory:deleteCustomInventory(invId)
> > ```
>
> > [accordion] registerInventory
> >
> > &#x20;register custom inventory
> >
> > **data** `table` *required*
> >
> > `{ id:string, name:string, limit:number, acceptWeapons:boolean, shared:boolean, ignoreItemStackLimit:boolean, whitelistItems:boolean, UsePermissions:boolean, UseBlackList:boolean, whitelistWeapons:boolean,webhook:string }`
> >
> > ```lua theme={null}
> > exports.vorp_inventory:registerInventory(data)
> > ```
>
> > [accordion] AddPermissionMoveToCustom
> >
> > &#x20;add permissions to move item to inventory by job and grade
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **jobName** `string` *required*
> >
> > job name
> >
> > **jobgrade** `number` *required*
> >
> > job grade
> >
> > ```lua theme={null}
> > exports.vorp_inventory:AddPermissionMoveToCustom(invId, jobName, jobgrade)
> > ```
>
> > [accordion] AddPermissionTakeFromCustom
> >
> > &#x20;add permissions to take item from inventory by job and grade
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **jobName** `string` *required*
> >
> > job name
> >
> > **jobgrade** `number` *required*
> >
> > job grade
> >
> > ```lua theme={null}
> > exports.vorp_inventory:AddPermissionTakeFromCustom(invId, jobName, jobgrade)
> > ```
>
> > [accordion] BlackListCustomAny
> >
> > &#x20;black list items or weapons
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **item** `string` *required*
> >
> > item name | weapon name
> >
> > ```lua theme={null}
> > exports.vorp_inventory:BlackListCustomAny(invId, item)
> > ```
>
> > [accordion] removeInventory
> >
> > &#x20;remove inventory from session
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > ```lua theme={null}
> > exports.vorp_inventory:removeInventory(invId)
> > ```
>
> > [accordion] updateCustomInventorySlots
> >
> > &#x20;update inventory slots
> >
> > **invId** `string` *required*
> >
> > inventory id
> >
> > **slots** `number` *required*
> >
> > inventory slots
> >
> > ```lua theme={null}
> > exports.vorp_inventory:updateCustomInventorySlots(invId, slots)
> > ```
>
> > [accordion] openInventory
> >
> > &#x20;open inventory main or secondary
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **invId** `string`
> >
> > inventory id
> >
> > ```lua theme={null}
> > exports.vorp_inventory:openInventory(source, invId)
> > ```
>
> > [accordion] closeInventory
> >
> > &#x20;close inventory main or secondary
> >
> > **source** `int` *required*
> >
> > The player id
> >
> > **invId** `string`
> >
> > inventory id
> >
> > ```lua theme={null}
> > exports.vorp_inventory:closeInventory(source, invId)
> > ```
>
> > [accordion] openPlayerInventory
> >
> > &#x20;open player inventory
> >
> > **data** `table` *required*
> >
> > `{ source:int, target:int, title:string, blacklist:table, itemsLimit:table, timeout:number }`
> >
> > ```lua theme={null}
> > local data = {
> >     source = source, 
> >     target = target, 
> >     title = "Search inventory",
> >     blacklist = { -- OPTIONAL
> >         water = true, -- item name or weapon name
> >     },
> >     itemsLimit = { -- OPTIONAL
> >         weapons = { itemType = "item_weapon", limit = 1 }, -- how many weapons user is allowed to take
> >         items =   { itemType = "item_standard", limit = 2 }, -- how many items user is allowed to take
> >     },
> >     timeout = 60, -- OPTIONAL in seconds , if enabled when user reaches limits then a timeout is applied so player cant steal for that amount of time if removed then   once limit reached only after restart they can steal again
> > }
> >
> > exports.vorp_inventory:openPlayerInventory(data)
> > ```

***

## Events

> [!NOTE]
>
> Server Side only

Listen to when an item is used

```lua theme={null}
AddEventHandler("vorp_inventory:Server:OnItemUse",function(data)
    local source = data.source
    local itemName = data.item.name
    local itemMetadata = data.item.metadata
end)
```

Listen to when an item is created in player inventory

```lua OnItemCreated theme={null}
AddEventHandler("vorp_inventory:Server:OnItemCreated",function(data,source)
    -- data.count, data.name, data.metadata
end)
```

Listen to when an item is removed from player inventory

```lua OnItemRemoved theme={null}
AddEventHandler("vorp_inventory:Server:OnItemRemoved",function(data,source)
    -- data.count , data.name , data.metadata
end)
```

Listen to when an item is taken from custom inventory

```lua OnItemTakenFromCustomInventory theme={null}
AddEventHandler("vorp_inventory:Server:OnItemTakenFromCustomInventory", function(item, invId, source)
    -- item.amount , item.name, item.id, item.metadata
end)
```

Listen to when an item is moved to custom inventory

```lua OnItemMovedToCustomInventory theme={null}
AddEventHandler("vorp_inventory:Server:OnItemMovedToCustomInventory", function(item, invId, source)
    -- item.amount , item.name, item.id, item.metadata
end)
```

Listen for inventory state change `(opens or closes)` including custom inventories

```lua OnInvStateChange theme={null}
AddEventHandler("vorp_inventory:Client:OnInvStateChange",function(boolean)
    print(boolean)
end)
```

Block player inventory from server or client side

```lua OnInvBlock server theme={null}
TriggerClientEvent("vorp_inventory:blockInventory", player_id, true or false)
```

```lua OnInvBlock client theme={null}
  TriggerEvent("vorp_inventory:blockInventory", true or false)
```

> [!NOTE]
>
> Client Side only

Listen to when a weapon is equipped

```lua onWeaponEquipped theme={null}
AddEventHandler("vorp_inventory:onWeaponEquipped", function(components, weaponId, name, isDual, defaultAttachments)
    -- components: table of the equipped components, weaponId: weapon id, name: weapon name, isDual: boolean, defaultAttachments: table
end)
```

Listen to when a component is added to a weapon

```lua componentAdded theme={null}
AddEventHandler("vorp_inventory:componentAdded", function(weaponId, component, category)
    -- weaponId: weapon id, component: component name, category: slot category
end)
```

Listen to when a component is removed from a weapon

```lua componentRemoved theme={null}
AddEventHandler("vorp_inventory:componentRemoved", function(weaponId, component, category)
    -- weaponId: weapon id, component: component name, category: slot category
end)
```

## Statebags

contains data from the current weapon used in the inventory or last weapon used.

> [!NOTE]
>
> client side

```lua GetEquippedWeaponData theme={null}
local key = string.format("GetEquippedWeaponData_%d",weaponHash)
local data = LocalPlayer.state[key]
local serial = data.serialNumber
local id = data.weaponId
```

> [!NOTE]
>
> server side

```lua GetEquippedWeaponData theme={null}
local key = string.format("GetEquippedWeaponData_%d",weaponHash)
local data = Player(source).state[key]
local serial = data.serialNumber
local id = data.weaponId
```

check if inventory is active (open or closed) including custom inventories

> [!NOTE]
>
> client side

```lua IsInvActive theme={null}
LocalPlayer.state.IsInvActive
```

> [!NOTE]
>
> server side

```lua IsInvActive theme={null}
Player(source).state.IsInvActive
```

## Global Statebags

returns timestamp from server to be used in client

```lua theme={null}
local timestamp = GlobalState.TimeNow
-- Get hours, minutes and seconds from timestamp
local seconds = GlobalState.TimeNow % 60
local minutes = math.floor(GlobalState.TimeNow / 60) % 60 
local hours = math.floor(GlobalState.TimeNow / 3600) % 24
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.