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 ()
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
returns
true 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 )
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 )
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