This documentation is for developers who are making scripts for VORP Core Framework
Exports
These exports are client side only!
Getters
get all user inventory itemsreturns a table containing all the items in the inventory
local result = exports . vorp_inventory : getInventoryItems ()
get user inventory itemreturns a table containing the item name,label,weight,desc metadata, percentage
local result = exports . vorp_inventory : getInventoryItem ()
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
local result = exports . vorp_inventory : getServerItem ( "water" )
print ( result . label )
close inventoryexports . vorp_inventory : closeInventory ()
These exports are server side only!
Weapons
Items
Inventory items
Inventory weapons
Inventory misc
Getters
get all user ammocallback function syncronous or asyncronous
returns a table containing all the ammo
exports . vorp_inventory : getUserAmmo ( source , callback )
check if player can carry weaponscallback 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
exports . vorp_inventory : canCarryWeapons ( source , amount , callback , weaponName )
get user inventory weaponcallback function syncronous or asyncronous
{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}
exports . vorp_inventory : getUserWeapon ( source , callback , weaponId )
get user inventory weaponscallback function syncronous or asyncronous
{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}
exports . vorp_inventory : getUserInventoryWeapons ( source , callback )
get weapon bulletscallback function syncronous or asyncronous
exports . vorp_inventory : getWeaponBullets ( source , weaponID , callback )
get weapon componentscallback function syncronous or asyncronous
returns a table containing the weapon components
exports . vorp_inventory : getWeaponComponents ( source , weaponId , callback )
Setters
set weapon custom descriptioncallback function syncronous or asyncronous
returns true if the description was successfully set
exports . vorp_inventory : setWeaponCustomDesc ( weaponId , desc , cb )
set weapon custom labelcallback function syncronous or asyncronous
returnstrue if the label was successfully set
exports . vorp_inventory : setWeaponCustomLabel ( weaponId , label , cb )
set weapon serial numbercallback function syncronous or asyncronous
returns true if the serial number was successfully set
exports . vorp_inventory : setWeaponSerialNumber ( weaponId , serial , cb )
remove weapon from user inventorycallback function syncronous or asyncronous
returns true if the weapon was successfully removed
exports . vorp_inventory : subWeapon ( source , weaponId , callback )
give weapon to usercallback function syncronous or asyncronous
returns true if the weapon was successfully given
exports . vorp_inventory : giveWeapon ( source , weaponId , target , callback )
create weaponcallback function syncronous or asyncronous
leave this as nil, this is used internally only
custom serial number for weapon
exports . vorp_inventory : createWeapon ( source , weaponName , ammo , components , comps , callback , serial , label , desc )
delete weaponcallback function syncronous or asyncronous
exports . vorp_inventory : deleteWeapon ( source , weaponId , callback )
add bulletscallback function syncronous or asyncronous
returns true if the bullets were successfully added
exports . vorp_inventory : addBullets ( source , bulletType , amount , callback )
remove bullets from weaponcallback function syncronous or asyncronous
returns true if the bullets were successfully removed
exports . vorp_inventory : subBullets ( weaponId , bulletType , amount , callback )
remove all user ammoexports . vorp_inventory : removeAllUserAmmo ( source )
Getters
check if player can carry the item before adding it to the inventoryThe callback function syncronous or asyncronous
returns true if the player can carry the item
exports . vorp_inventory : canCarryItem ( source , item , amount , callback )
gets all the items in the player inventoryThe callback function syncronous or asyncronous
returns a table containing all the items in the inventory
exports . vorp_inventory : getUserInventoryItems ( source , callback )
get item amount from player inventorycallback function for syncronous or asyncronous
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
exports . vorp_inventory : getItemCount ( source , callback , item , metadata , percentage )
get DB itemcallback function asyncronous or syncronous
returns a table containing item info
exports . vorp_inventory : getItemDB ( item , callback )
get item by main idcallback 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}
exports . vorp_inventory : getItemById ( source , id , callback )
get item datacallback function syncronous or asyncronous
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}
exports . vorp_inventory : getItem ( source , item , callback , metadata , percentage )
Setters
add item to usercallback function syncronous or asyncronous
if true will not trigger the event OnItemCreated
returns true if the item was successfully added
exports . vorp_inventory : addItem ( source , item , amount , metadata , callback , event )
remove item from user inventorycallback 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
exports . vorp_inventory : subItem ( source , item , amount , metadata , callback , event , percentage )
remove item from user inventory by its id exort available on verion 3.9 and up lower versions uses subItemIDcallback function syncronous or asyncronous
event OnItemRemoved to be fired, if true it wont be sent, false or nil it will fire the event
returns true if the item was successfully removed
exports . vorp_inventory : subItemById ( source , itemId , callback , event , amount )
register usable item
Items cant be registered twice they must be unique
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
exports . vorp_inventory : registerUsableItem ( item , callback , resourceName )
un register usable item when you stop a script for example
Items cant be registered twice they must be unique
exports . vorp_inventory : unRegisterUsableItem ( item )
Getters
getCustomInventoryItemCount
get custom inventory item countcallback function syncronous or asyncronous
returns the amount of items in the inventory
exports . vorp_inventory : getCustomInventoryItemCount ( invid , itemName , callback )
get custom inventory itemscallback function syncronous or asyncronous
returns a table containing all the items in the inventory
exports . vorp_inventory : getCustomInventoryItems ( invid , callback )
Setters
removeItemFromCustomInventory
remove item from custom inventorycallback function syncronous or asyncronous
returns true if the item was successfully removed
exports . vorp_inventory : removeItemFromCustomInventory ( invid , itemName , callback )
updateCustomInventoryItem
update item in custom inventorycallback function syncronous or asyncronous
returns true if the item was successfully updated
exports . vorp_inventory : updateCustomInventoryItem ( invId , item_id , metadata , amount , callback )
addItemsToCustomInventory
add items to custom inventorycharidentifier 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
exports . vorp_inventory : addItemsToCustomInventory ( invid , items , charid , callback )
setCustomInventoryItemLimit
if in registerCustomInventory you set whitelistItems true then use this export to set which items are whitelisted and their amountcallback function syncronous or asyncronous
returns true if the limit was successfully set
exports . vorp_inventory : setCustomInventoryItemLimit ( invId , item , limit , callback )
Getters
getCustomInventoryWeapons
get custom inventory weaponscallback function syncronous or asyncronous
returns a table containing all the weapons in the inventory
exports . vorp_inventory : getCustomInventoryWeapons ( invid , callback )
getCustomInventoryWeaponCount
get custom inventory weapon countcallback function syncronous or asyncronous
returns the amount of weapons in the inventory
exports . vorp_inventory : getCustomInventoryWeaponCount ( invid , weaponName , callback )
Setter
removeCustomInventoryWeaponById
remove weapon from custom inventory by weapon idcallback function syncronous or asyncronous
returns true if the weapon was successfully removed
exports . vorp_inventory : removeCustomInventoryWeaponById ( invId , weapon_id , callback )
removeWeaponFromCustomInventory
remove weapon from custom inventorycallback function syncronous or asyncronous
returns true if the weapon was successfully removed
exports . vorp_inventory : removeWeaponFromCustomInventory ( invid , weaponName , callback )
addWeaponsToCustomInventory
add weapons to custom inventory{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
exports . vorp_inventory : addWeaponsToCustomInventory ( invid , weapons , charid , callback )
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 amountcallback function syncronous or asyncronous
returns true if the limit was successfully set
exports . vorp_inventory : setCustomInventoryWeaponLimit ( invId , weapon , limit , callback )
Getters
isCustomInventoryRegistered
check if inventory is registeredcallback function syncronous or asyncronous
returns true if the inventory is registered
exports . vorp_inventory : isCustomInventoryRegistered ( id , callback )
AddCharIdPermissionTakeFromCustom
add permissions using charidsexports . vorp_inventory : AddCharIdPermissionTakeFromCustom ( id , charid , state )
AddCharIdPermissionMoveToCustom
add permissions using charidsexports . vorp_inventory : AddCharIdPermissionMoveToCustom ( id , charid , state )
get cached inventory slotscallback function syncronous or asyncronous
exports . vorp_inventory : getCustomInventorySlots ( invId , callback )
Setters
delete custom inventory from data base and cacheexports . vorp_inventory : deleteCustomInventory ( invId )
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 }
exports . vorp_inventory : registerInventory ( data )
AddPermissionMoveToCustom
add permissions to move item to inventory by job and gradeexports . vorp_inventory : AddPermissionMoveToCustom ( invId , jobName , jobgrade )
AddPermissionTakeFromCustom
add permissions to take item from inventory by job and gradeexports . vorp_inventory : AddPermissionTakeFromCustom ( invId , jobName , jobgrade )
black list items or weaponsexports . vorp_inventory : BlackListCustomAny ( invId , item )
remove inventory from sessionexports . vorp_inventory : removeInventory ( invId )
updateCustomInventorySlots
update inventory slotsexports . vorp_inventory : updateCustomInventorySlots ( invId , slots )
open inventory main or secondaryexports . vorp_inventory : openInventory ( source , invId )
close inventory main or secondaryexports . vorp_inventory : closeInventory ( source , invId )
open player inventory{ source:int, target:int, title:string, blacklist:table, itemsLimit:table, timeout:number }
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
Listen to when an item is used
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
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
AddEventHandler ( "vorp_inventory:Server:OnItemRemoved" , function ( data , source )
-- data.count , data.name , no metadata is passed here
end )
Listen to when an item is taken from custom inventory
OnItemTakenFromCustomInventory
AddEventHandler ( "vorp_inventory:Server:OnItemTakenFromCustomInventory" , function ( item , invId , source )
-- item.amount , item.name, item.id
end )
Listen to when an item is moved to custom inventory
OnItemMovedToCustomInventory
AddEventHandler ( "vorp_inventory:Server:OnItemMovedToCustomInventory" , function ( item , invId , source )
-- item.amount , item.name, item.id
end )
Listen for inventory state change (opens or closes) including custom inventories
AddEventHandler ( "vorp_inventory:Client:OnInvStateChange" , function ( boolean )
print ( boolean )
end )
Block player inventory from server or client side
TriggerClientEvent ( "vorp_inventory:blockInventory" , player_id , true or false )
TriggerEvent ( "vorp_inventory:blockInventory" , true or false )
Statebags
contains data from the current weapon used in the inventory or last weapon used.
local key = string.format ( "GetEquippedWeaponData_%d" , weaponHash )
local data = LocalPlayer . state [ key ]
local serial = data . serialNumber
local id = data . weaponId
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
LocalPlayer . state . IsInvActive
Player ( source ). state . IsInvActive
Global Statebags
returns timestamp from server to be used in client
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