Inventory
Allows interactions with the players inventory
Reference
Functions
- impulse.Inventory.ClassToNetID(class)
- impulse.Inventory.DBAddItem(ownerid, class[, storageType=1])
- impulse.Inventory.DBClearInventory(ownerid[, storageType=1])
- impulse.Inventory.DBRemoveItem(ownerid, class[, storageType=1[, limit=1]])
- impulse.Inventory.DBUpdateStoreType(ownerid, classname[, limit=1], oldStorageType, newStorageType)
- impulse.Inventory.GetCraftingTime(class)
- impulse.Inventory.PickRandomCraftSound([craftType=generic])
- impulse.Inventory.SpawnBench(class, pos, ang)
- impulse.Inventory.SpawnItem(class, pos[, bannedPlayer[, killTime]])
- impulse.RegisterBench(benchData)
- impulse.RegisterItem(itemData)
- impulse.RegisterMixture(mixData)
- meta:CanHoldItem(class[, amount=1])
- meta:CanHoldItemStorage(class[, amount=1])
- meta:CanMakeMix(class)
- meta:ClearIllegalInventory([storageType=1])
- meta:ClearInventory([storageType=1])
- meta:ClearRestrictedInventory([storageType=1])
- meta:DropInventoryItem(itemid)
- meta:GetInventory([storageType=1])
- meta:GetMaxInventoryStorage()
- meta:GiveInventoryItem(itemclass[, storageType=1[, restricted=false[, isLoaded=false[, moving=false[, clip]]]]])
- meta:HasIllegalInventoryItem([storageType=1])
- meta:HasInventoryItem(itemId)
- meta:HasInventoryItem(class[, amount=1])
- meta:HasInventoryItemSpecific(itemID[, storageType=1])
- meta:HasInventoryItemStorage(class[, amount=1])
- meta:IsInventoryItemRestricted(itemID[, storageType=1])
- meta:MoveInventoryItem(itemid, from, to)
- meta:MoveInventoryItemMass(class, from, to, amount)
- meta:SetInventoryItemEquipped(itemID, state)
- meta:TakeInventoryItem(itemID[, storageType=1[, moving=false]])
- meta:TakeInventoryItemClass(class[, storageType=1[, amount=1]])
- meta:UnEquipInventory()
- meta:UseInventoryItem(itemid)
Tables
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[, storageType=1])
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
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
impulse.Inventory.DBClearInventory(ownerid[, storageType=1])
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, class[, storageType=1[, limit=1]])
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
-
class
string
Class name of the item to remove
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
-
limit
int
default: 1
The amount of items to remove
impulse.Inventory.DBUpdateStoreType(ownerid, classname[, limit=1], oldStorageType, newStorageType)
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
-
classname
string
Class name of the item to update
-
limit
int
default: 1
The amount of items to update
-
oldStorageType
int
Old storage type (1 is player inventory, 2 is storage)
-
newStorageType
int
New storage type (1 is player inventory, 2 is storage)
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.PickRandomCraftSound([craftType=generic])
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.RegisterBench(benchData)
View source »Registers a new workbench
Parameters
-
benchData
Bench data
impulse.RegisterItem(itemData)
View source »Registers a new inventory item
Parameters
-
itemData
Item data
impulse.RegisterMixture(mixData)
View source »Registers a new mixture
Parameters
-
mixData
Mixture data
meta:CanHoldItem(class[, amount=1])
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
meta:CanHoldItemStorage(class[, amount=1])
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
meta:CanMakeMix(class)
View source »Returns if a player can make a mix
Parameters
-
class
string
Mixture class name
Returns
-
bool
Can make mixture
meta:ClearIllegalInventory([storageType=1])
View source »Clears illegal items from a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
meta:ClearInventory([storageType=1])
View source »Clears a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
meta:ClearRestrictedInventory([storageType=1])
View source »Clears restricted items from a players inventory
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
meta:DropInventoryItem(itemid)
View source »Drops a specific inventory item
Parameters
-
itemid
int
Item ID
meta:GetInventory([storageType=1])
View source »Gets a players inventory table
Parameters
-
storageType
int
default: 1
Storage type (1 is player inventory, 2 is storage)
Returns
-
table
Inventory
meta:GetMaxInventoryStorage()
View source »Returns the max capacity of the players storage box
Returns
-
int
Capacity (in kg)
meta:GiveInventoryItem(itemclass[, storageType=1[, restricted=false[, isLoaded=false[, moving=false[, clip]]]]])
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)
-
restricted
boolean
default: false
Is item restricted
-
isLoaded
boolean
default: false
(INTERNAL) Used for first time setup when player connects
-
moving
boolean
default: false
(INTERNAL) Is item just being moved? (stops database requests)
-
clip
int
optional
(INTERNAL) (Only used for weapons) Item clip
Returns
-
int
ItemID
meta:HasIllegalInventoryItem([storageType=1])
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
meta: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
meta:HasInventoryItem(class[, amount=1])
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
meta:HasInventoryItemSpecific(itemID[, storageType=1])
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
meta:HasInventoryItemStorage(class[, amount=1])
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
meta:IsInventoryItemRestricted(itemID[, storageType=1])
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
meta: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
meta: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
meta:SetInventoryItemEquipped(itemID, state)
View source »Sets a specific inventory item as equipped or not
Parameters
-
itemID
int
Item ID
-
state
boolean
Is equipped
meta:TakeInventoryItem(itemID[, storageType=1[, moving=false]])
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)
-
moving
boolean
default: false
(INTERNAL) Is item just being moved? (stops database requests)
Returns
-
int
Clip
meta:TakeInventoryItemClass(class[, storageType=1[, amount=1]])
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
meta:UnEquipInventory()
View source »Un equips all iventory items for a player
meta:UseInventoryItem(itemid)
View source »Uses a specific inventory item
Parameters
-
itemid
int
Item ID
Tables
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]