Inventory
Allows interactions with the players inventory
Functions
impulse.Inventory.ClassToNetID(class)
View source »Used to convert the class to the item's NetID (or table ref)
Parameters
-
class
string
Item class name
Returns
-
int
Item net ID
impulse.Inventory.DBAddItem(ownerid, class, netid, storageType, flags, metadata)
View source »Inserts an inventory item into the database. This can be used to control the inventory of offline users
Parameters
-
ownerid
int
OwnerID number
-
class
string
Class name of the item to add
-
netid
int
NetID of the item.
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
flags
int
default: 0
Bitflags for the item
-
metadata
table
default: {}
Metadata for the item
impulse.Inventory.DBChangeOwner(databaseid, newowner)
View source »Changes the owner of an inventory item in the database. This can be used to control the inventory of offline users
Parameters
-
databaseid
int
The database ID of the item to change the owner of
-
newowner
int
The new owner ID
impulse.Inventory.DBClearInventory(ownerid, storageType)
View source »Clears a players inventory. This can be used to control the inventory of offline users
Parameters
-
ownerid
int
OwnerID number
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
impulse.Inventory.DBRemoveItem(ownerid, invid)
View source »Deletes an inventory item from the database. This can be used to control the inventory of offline users
Parameters
-
ownerid
int
OwnerID number
-
invid
int
Inventory item ID
impulse.Inventory.DBUpdateItem(ownerid, invid, storageType, flags, metadata)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Updates an inventory item in the database. This can be used to control the inventory of offline users, primarily used for updating item flags and metadata. Use with caution.
Parameters
-
ownerid
int
OwnerID number.
-
invid
int
Inventory item ID.
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
flags
int
default: 0
Bitflags for the item
-
metadata
table
default: {}
Metadata for the item
impulse.Inventory.DBUpdateStoreType(ownerid, invid, oldStorageType, newStorageType, queueQuery)
View source »Updates the storage type for an existing item. This can be used to control the inventory of offline users
Parameters
-
ownerid
int
OwnerID number
-
invid
int
Inventory item ID
-
oldStorageType
int
Old storage type (1 is player inventory, 2 is storage)
-
newStorageType
int
New storage type (1 is player inventory, 2 is storage)
-
queueQuery
boolean
Queue the query to be executed later, this is used for mass updates to prevent spamming the database.
impulse.Inventory.GetCraftingTime(class)
View source »Used to get the crafting time and the sounds to play
Parameters
-
class
string
Item class name
Returns
-
int
Time
-
table
Table of sounds
impulse.Inventory.Item(ownerid, storagetype, invid)
View source »Returns a complete object reference to an inventory item, this is used to call functions on the item or otherwise access it's data. This is used to avoid complex data structures and to make it easier to access the data.
Parameters
-
ownerid
int
Owner ID
-
storagetype
int
Storage type
-
invid
int
Inventory ID
Returns
-
table
Item data
impulse.Inventory.PickRandomCraftSound(craftType)
View source »Used to pick a random crafting sound for the correct crafting type
Parameters
-
craftType
string
default: generic
Crafting type
Returns
-
string
The random crafting sound based on the crafting type (eg: if type is wood then return wood2.wav)
See Also
impulse.Inventory.SpawnBench(class, pos, ang)
View source »Spawns a workbench
Parameters
-
class
string
Class name of the workbench
-
pos
vector
limit The spawn position
-
ang
angle
The spawn angle
Returns
-
entity
Spawned workbench
impulse.Inventory.SpawnItem(class, pos, bannedPlayer, killTime)
View source »Spawns an inventory item as an Entity
Parameters
-
class
string
Class name of the item to spawn
-
pos
vector
limit The spawn position
-
bannedPlayer
Player
optional
Player to ban from picking up
-
killTime
int
optional
Time until the item is removed automatically
Returns
-
entity
Spawned item
impulse.MakeCallable(itemData, itemMeta)
View source »Combines two tables together, used for items and stuff.
Parameters
-
itemData
table
Item data
-
itemMeta
table
Item meta
Returns
-
table
Combined table
impulse.RegisterBench(benchData)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Registers a new workbench
Parameters
-
benchData
Bench data
impulse.RegisterItem(itemData)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Registers a new inventory item
Parameters
-
itemData
Item data
impulse.RegisterMixture(mixData)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Registers a new mixture
Parameters
-
mixData
Mixture data
impulse.RegisterVendor(vendor)
View source »Registers a vendor.
Parameters
-
vendor
table
The vendor to register.
Player:CanHoldItem(class, amount)
View source »Returns if a player can hold an item in their local inventory
Parameters
-
class
string
Item class name
-
amount
int
default: 1
Amount of the item
Returns
-
bool
Can hold item
Player:CanHoldItemStorage(class, amount)
View source »Returns if a player can hold an item in their storage chest
Parameters
-
class
string
Item class name
-
amount
int
default: 1
Amount of the item
Returns
-
bool
Can hold item
Player:CanMakeMix(class)
View source »Returns if a player can make a mix
Parameters
-
class
string
Mixture class name
Returns
-
bool
Can make mixture
Player:ClearIllegalInventory(storageType)
View source »Clears illegal items from a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Player:ClearInventory(storageType)
View source »Clears a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Player:ClearRestrictedInventory(storageType)
View source »Clears restricted items from a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Player:DropInventoryItem(itemid)
View source »Drops a specific inventory item
Parameters
-
itemid
int
Item ID
Player:GetInventory(storageType)
View source »Gets a players inventory table
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Returns
-
table
Inventory
Player:GetMaxInventoryStorage()
View source »Returns the max capacity of the players storage box
Returns
-
int
Capacity (in lbs)
Player:GiveInventoryItem(itemclass, storageType, itemflags, metadata, databaseid, isLoaded)
View source »Gives an inventory item to a player
Parameters
-
itemclass
string
Item class name
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
itemflags
int
optional
Item flags.
-
metadata
table
default: {}
Item metadata.
-
databaseid
int
optional
Database ID of item, nil means this is a new item, rather than operating on an existing item in the database.
-
isLoaded
boolean
optional
Is this being called from the database load function, if so, don't abide by the same rules as a normal give.
Returns
-
int
ItemID
Player:GiveRestrictedInventoryItem(itemclass, itemflags, metadata)
View source »Gives an inventory item to a player
Parameters
-
itemclass
string
Item class name
-
itemflags
int
optional
Item flags.
-
metadata
table
default: {}
Item metadata.
Returns
-
int
ItemID
Player:HasIllegalInventoryItem(storageType)
View source »Returns if a player has an illegal inventory item
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Returns
-
bool
Has illegal item
-
int
Item ID of illegal item
Player:HasInventoryItem(itemId)
View source »Returns if a client has an inventory item and how much they have
Parameters
-
itemId
int
Item Network ID (use impulse.Inventory.ClassToNetID)
Returns
-
bool
Has item
-
int
Amount
See Also
Player:HasInventoryItem(class, amount)
View source »Returns if a player has an item in their local inventory
Parameters
-
class
string
Item class name
-
amount
int
default: 1
Amount of the item
Returns
-
bool
Has item
Player:HasInventoryItemSpecific(itemID, storageType)
View source »Returns if a player has an specific item. This is used to check if they have the exact item, not just an item of the class specified
Parameters
-
itemID
int
Item ID
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Returns
-
bool
Has item
Player:HasInventoryItemStorage(class, amount)
View source »Returns if a player has an item in their storage chest
Parameters
-
class
string
Item class name
-
amount
int
default: 1
Amount of the item
Returns
-
bool
Has item
Player:IsInventoryItemRestricted(itemID, storageType)
View source »Returns if a specific inventory item is restricted
Parameters
-
itemID
int
Item ID
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Returns
-
bool
Is restricted
Player:MoveInventoryItem(itemid, from, to)
View source »Moves a specific inventory item across storages (to move several of the same items use MoveInventoryItemMass as it is faster)
Parameters
-
itemid
int
Item ID
-
from
int
Old storage type
-
to
int
New storage type
Player:MoveInventoryItemMass(class, from, to, amount)
View source »Moves a collection of the same items across storages
Parameters
-
class
string
Item class name
-
from
int
Old storage type
-
to
int
New storage type
-
amount
int
Amount to move
Player:RefundMix(class)
View source »Refunds a player for a mix, used in Landis for obsolete items.
Parameters
-
class
string
Mixture class name
Player:SetInventoryItemEquipped(itemID, state)
View source »Sets a specific inventory item as equipped or not
Parameters
-
itemID
int
Item ID
-
state
boolean
Is equipped
Player:TakeInventoryItem(itemID, storageType, keep, dontKeepLocally)
View source »Takes an inventory item from a player
Parameters
-
itemID
int
Item ID
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
keep
boolean
default: false
Keep the item in the database and don't remove it, instead assigns it to ownerid 0, removed at startup/shutdown.
-
dontKeepLocally
boolean
default: false
Don't keep the item in the local inventory table, only the database, if nil follows keep.
Returns
-
int
Database ID of item removed
Player:TakeInventoryItemClass(class, storageType, amount)
View source »Takes an item from a players inventory by class name
Parameters
-
class
string
Item class name
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
amount
int
default: 1
Amount to take
Player:UnEquipInventory()
View source »Un equips all iventory items for a player
Player:UseInventoryItem(itemid)
View source »Uses a specific inventory item
Parameters
-
itemid
int
Item ID
Tables
BENCH
View source »Fields that are usable for benches.
Fields
-
Class
string
-
Name
string
-
Desc
string
-
Model
string
-
Skill
string
-
Illegal
boolean
-
NotIllegalFor
Table of team IDs that the bench isn't illegal for.
-
CanUse
function
CraftingTypes
View source »A collection of crafting types, each uses a different set of sounds
Fields
-
[chemical]
-
[electronics]
-
[fabric]
-
[fuel]
-
[generic]
-
[gunmetal]
-
[metal]
-
[nuclear]
-
[plastic]
-
[powder]
-
[rock]
-
[water]
-
[wood]
INV_ENUM
View source »Enums indicating where an item is stored.
Fields
-
INV_CONFISCATED
Indicates a confiscated item.
-
INV_PLAYER
Indicates an item located in a players current inventory.
-
INV_STORAGE
Indicates an item stored in a players storage box.
ITEM
View source »Fields that are available for items.
Fields
-
UniqueID
string
-
WeaponClass
string
optional
-
AttachmentClass
string
optional
-
Weight
number
-
CraftSound
string
-
CraftTime
number
-
Name
string
-
Desc
string
-
Model
string
-
FOV
number
-
NoCenter
boolean
-
Droppable
boolean
-
DropOnDeath
boolean
-
DropIfRestricted
boolean
-
DropOnDeathIfRestricted
boolean
-
CraftIfRestricted
boolean
-
Illegal
boolean
-
CanStack
boolean
-
Colour
color
-
Equipable
boolean
-
EquipGroup
string
-
CanEquip
function
-
OnEquip
function
-
UnEquip
function
-
UseTime
number
-
FreezeOwnerOnUse
boolean
-
CanUse
function
-
OnUse
function
-
CustomActions
Use keys paired to functions for custom interactions.
MIX
View source »Fields that are usable for mixtures.
Fields
-
Class
string
-
Level
int
-
Bench
string
-
Skill
string
-
Output
string
-
Input
Table, keys are UniqueIDs for items, and the value is a table with a "take" key and an integer.
Storables
View source »Storable attributes
Fields
-
STORABLE_ANY
Default.
-
STORABLE_GLOBAL
Global storage containers, owned storage containers cannot hold them.
-
STORABLE_LOCAL
Local storage containers can be used to store these items, global cannot be used to store them.
-
STORABLE_NONE
Cannot be stored in any storage container.