Inventory
Documentation for vorp inventory system
This documentation is for developers who are making scripts for VORP Core Framework
Exports
Getters
getInventoryItems
getInventoryItems
Getters
getInventoryItems
getInventoryItems
closeInventory
closeInventory
close inventory
Getters
getUserAmmo
getUserAmmo
canCarryWeapons
canCarryWeapons
check if player can carry weapons
The player id
amount of weapons
callback function syncronous or asyncronous
weapon name or hash its needed to check weight since 3.6
returns
true if the player can carry the weapons
getUserWeapon
getUserWeapon
get user inventory weapon
The player id
callback function syncronous or asyncronous
weapon id
{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}
getUserInventoryWeapons
getUserInventoryWeapons
getWeaponBullets
getWeaponBullets
getWeaponComponents
getWeaponComponents
Setters
setWeaponCustomDesc
setWeaponCustomDesc
setWeaponCustomLabel
setWeaponCustomLabel
setWeaponSerialNumber
setWeaponSerialNumber
subWeapon
subWeapon
giveWeapon
giveWeapon
createWeapon
createWeapon
create weapon
The player id
weapon name
amount of ammo
weapon components
weapon components
callback function syncronous or asyncronous
leave this as nil, this is used internally only
custom serial number for weapon
custom label for weapon
custom desc for weapons
if async
deleteWeapon
deleteWeapon
addBullets
addBullets
subBullets
subBullets
removeAllUserAmmo
removeAllUserAmmo
Getters
getUserAmmo
getUserAmmo
canCarryWeapons
canCarryWeapons
check if player can carry weapons
The player id
amount of weapons
callback function syncronous or asyncronous
weapon name or hash its needed to check weight since 3.6
returns
true if the player can carry the weapons
getUserWeapon
getUserWeapon
get user inventory weapon
The player id
callback function syncronous or asyncronous
weapon id
{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}
getUserInventoryWeapons
getUserInventoryWeapons
getWeaponBullets
getWeaponBullets
getWeaponComponents
getWeaponComponents
Setters
setWeaponCustomDesc
setWeaponCustomDesc
setWeaponCustomLabel
setWeaponCustomLabel
setWeaponSerialNumber
setWeaponSerialNumber
subWeapon
subWeapon
giveWeapon
giveWeapon
createWeapon
createWeapon
create weapon
The player id
weapon name
amount of ammo
weapon components
weapon components
callback function syncronous or asyncronous
leave this as nil, this is used internally only
custom serial number for weapon
custom label for weapon
custom desc for weapons
if async
deleteWeapon
deleteWeapon
addBullets
addBullets
subBullets
subBullets
removeAllUserAmmo
removeAllUserAmmo
Getters
canCarryItem
canCarryItem
getUserInventoryItems
getUserInventoryItems
getItemCount
getItemCount
get item amount from player inventory
The player id
callback function for syncronous or asyncronous
item name
item metadata
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
returns
the amount of items in the inventory
getItemDB
getItemDB
getItemById
getItemById
get item by main id
The player id
item id
callback function syncronous or asyncronous
{id:number, label:string, name:string, metadata:table, group:number, type:string, count:number, limit:number,canUse:boolean,percenage:integer,description:string,weight:number}
getItem
getItem
get item data
The player id
item name
callback function syncronous or asyncronous
item metadata
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
{id:number, label:string, name:string, metadata:table, group:number, type:string, count:number, limit:number,canUse:boolean,weight:number,desc:string,percentage:integer}
Setters
addItem
addItem
add item to user
The player id
item name
amount of item
item metadata
callback function syncronous or asyncronous
if true will not trigger the event OnItemCreated
returns
true if the item was successfully added
subItem
subItem
remove item from user inventory
The player id
item name
amount of item
item metadata
callback function syncronous or asyncronous
event OnItemRemoved to be fired, if true it wont be sent, false or nil it will fire the event
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
returns
true if the item was successfully removed
subItemById
subItemById
remove item from user inventory by its id exort available on verion 3.9 and up lower versions uses subItemID
The player id
item id
callback function syncronous or asyncronous
event OnItemRemoved to be fired, if true it wont be sent, false or nil it will fire the event
amount to remove
returns
true if the item was successfully removed
setItemMetadata
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
The player id
item id
{ description:string?, image:string?,label:string?,weight:number?}
description image label and weight are reserved keys if they are not defined they will be ignored, image is the image name to apply
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 syncronous or asyncronous
returns
true if the metadata was successfully set
registerUsableItem
registerUsableItem
register usable item
item name
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}
resource name for debug purposes so users can see in what resource this item is registered at
unRegisterUsableItem
unRegisterUsableItem
un register usable item when you stop a script for example
item name
Getters
getCustomInventoryItemCount
getCustomInventoryItemCount
getCustomInventoryItems
getCustomInventoryItems
Setters
removeCustomInventoryItemById
removeCustomInventoryItemById
removeItemFromCustomInventory
removeItemFromCustomInventory
updateCustomInventoryItem
updateCustomInventoryItem
addItemsToCustomInventory
addItemsToCustomInventory
add items to custom inventory
inventory id
items to add
charidentifier of the owner of the storage if custom inv is not shared , if its shared can be any characteridentifer
callback function syncronous or asyncronous
returns
true if the items were successfully added
setCustomInventoryItemLimit
setCustomInventoryItemLimit
if in registerCustomInventory you set whitelistItems true then use this export to set which items are whitelisted and their amount
inventory id
item name
item limit
callback function syncronous or asyncronous
returns
true if the limit was successfully set
Getters
getCustomInventoryWeapons
getCustomInventoryWeapons
getCustomInventoryWeaponCount
getCustomInventoryWeaponCount
Setter
removeCustomInventoryWeaponById
removeCustomInventoryWeaponById
removeWeaponFromCustomInventory
removeWeaponFromCustomInventory
addWeaponsToCustomInventory
addWeaponsToCustomInventory
add weapons to custom inventory
inventory id
{name: string, serial_number: string?, custom_label: string?, custom_desc: string?, components: table?}
charidentifier of the owner of the storage if custom inv is not shared , if its shared can be any characteridentifer
callback function syncronous or asyncronous
returns
true if the weapons were successfully added
setCustomInventoryWeaponLimit
setCustomInventoryWeaponLimit
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
inventory id
weapon name
weapon limit
callback function syncronous or asyncronous
returns
true if the limit was successfully set
Getters
isCustomInventoryRegistered
isCustomInventoryRegistered
AddCharIdPermissionTakeFromCustom
AddCharIdPermissionTakeFromCustom
AddCharIdPermissionMoveToCustom
AddCharIdPermissionMoveToCustom
getCustomInventorySlots
getCustomInventorySlots
registerInventory
registerInventory
register custom inventory
{ id:string, name:string, limit:number, acceptWeapons:boolean, shared:boolean, ignoreItemStackLimit:boolean, whitelistItems:boolean, UsePermissions:boolean, UseBlackList:boolean, whitelistWeapons:boolean,webhook:string }
AddPermissionMoveToCustom
AddPermissionMoveToCustom
AddPermissionTakeFromCustom
AddPermissionTakeFromCustom
BlackListCustomAny
BlackListCustomAny
removeInventory
removeInventory
updateCustomInventorySlots
updateCustomInventorySlots
openInventory
openInventory
closeInventory
closeInventory
openPlayerInventory
openPlayerInventory
open player inventory
{ source:int, target:int, title:string, blacklist:table, itemsLimit:table, timeout:number }
Events
Listen to when an item is used
Listen to when an item is created in player inventory
Listen to when an item is removed from player inventory
Listen for inventory state change (opens or closes)
including custom inventories
Statebags
contains data from the current weapon used in the inventory or last weapon used.
check if inventory is active (open or closed) including custom inventories
Global Statebags
returns timestamp from server to be used in client