Inventory
Documentation for vorp inventory system
This documentation is for developers who are making scripts for vorp core framework
Exports
Getters
returns a table containing all the items in the inventory
local result = exports.vorp_inventory:getInventoryItems()
the item name
returns a table containing the item name,label,weight,desc and metadata
local result = exports.vorp_inventory:getInventoryItems()
Getters
The player id
callback function syncronous or asyncronous
returns a table containing all the ammo
exports.vorp_inventory:getUserAmmo(source, callback)
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
exports.vorp_inventory:canCarryWeapons(source, amount,callback, weaponName)
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}
exports.vorp_inventory:getUserWeapon(source, callback,weaponId)
The player id
callback 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)
The player id
weapon id
callback function syncronous or asyncronous
weapon ammo
exports.vorp_inventory:getWeaponBullets(source,weaponID, callback)
The player id
weapon id
callback function syncronous or asyncronous
returns a table containing the weapon components
exports.vorp_inventory:getWeaponComponents(source, weaponId, callback)
Setters
weapon id
weapon description
callback function syncronous or asyncronous
returns true if the description was successfully set
exports.vorp_inventory:setWeaponCustomDesc(weaponId, desc, cb)
weapon id
weapon label
callback function syncronous or asyncronous
returns true if the label was successfully set
exports.vorp_inventory:setWeaponCustomLabel(weaponId, label, cb)
weapon id
weapon serial number
callback function syncronous or asyncronous
returns true if the serial number was successfully set
exports.vorp_inventory:setWeaponSerialNumber(weaponId, serial, cb)
The player id
weapon id
callback function syncronous or asyncronous
returns true if the weapon was successfully removed
exports.vorp_inventory:subWeapon(source, weaponId, callback)
The player id
weapon id
target id
callback function syncronous or asyncronous
returns true if the weapon was successfully given
exports.vorp_inventory:giveWeapon(source, weaponId, target,callback)
The player id
weapon name
amount of ammo
weapon components
weapon components
callback function syncronous or asyncronous
custom serial number for weapon
custom label for weapon
custom desc for weapons
if async
exports.vorp_inventory:createWeapon(source, weaponName, ammo, components, comps, callback,serial,label,desc)
The player id
weapon id
callback function syncronous or asyncronous
if async
exports.vorp_inventory:deleteWeapon(source, weaponId, callback)
The player id
bullet type
amount of bullets
callback function syncronous or asyncronous
returns true if the bullets were successfully added
exports.vorp_inventory:addBullets(source, bulletType, amount,callback)
weapon id
bullet type
amount of bullets
callback function syncronous or asyncronous
returns true if the bullets were successfully removed
exports.vorp_inventory:subBullets(weaponId, bulletType, amount,callback)
The player id
exports.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
end)
Listen to when an item is created in player inventory
AddEventHandler("vorp_inventory:Server:OnItemCreated",function(data,source)
print(json.encode(data),{ident = true})
end)
Listen to when an item is removed from player inventory
AddEventHandler("vorp_inventory:Server:OnItemRemoved",function(data,source)
print(json.encode(data),{ident = true})
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