ix.storage
Player manipulation of inventories.
This library provides an easy way for players to manipulate other inventories. The only functions that you should need are ix.storage.Open and ix.storage.Close. When opening an inventory as a storage item, it will display both the given inventory and the player's inventory in the player's UI, which allows them to drag items to and from the given inventory.
Example usage:
ix.storage.Open(client, inventory, {
name = "Filing Cabinet",
entity = ents.GetByIndex(3),
bMultipleUsers = true,
searchText = "Rummaging...",
searchTime = 4
})
Functions
ix.storage.AddReceiver(client, inventory, bDontSync)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Adds a receiver to a given inventory with a storage context.
Parameters
-
client
Player
Player to sync storage for
-
inventory
Inventory
Inventory to sync storage for
-
bDontSync
boolean
Whether or not to skip syncing the storage to the client. If this is
true
, the storage panel will not show up for the player
ix.storage.Close(inventory)
View source »Forcefully makes clients close this inventory if they have it open.
Parameters
-
inventory
Inventory
Inventory to close
ix.storage.CreateContext(inventory, info)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Creates a storage context on the given inventory.
Parameters
-
inventory
Inventory
Inventory to create a storage context for
-
info
table
Information to store on the context
ix.storage.InUse(inventory)
View source »Returns whether or not the given inventory has a storage context and is being looked at by other players.
Parameters
-
inventory
Inventory
Inventory to check
Returns
-
bool
Whether or not inventory is in use
ix.storage.InUseBy(inventory, client)
View source »Returns whether or not an inventory is in use by a specific player.
Parameters
-
inventory
Inventory
Inventory to check
-
client
Player
Player to check
Returns
-
bool
Whether or not the player is using the given inventory
ix.storage.Open(client, inventory, info)
View source »Makes a player open an inventory that they can interact with. This can be called multiple times on the same inventory, if the info passed allows for multiple users.
Parameters
-
client
Player
Player to open the inventory for
-
inventory
Inventory
Inventory to open
-
info
table
StorageInfoStructure describing the storage properties
ix.storage.RemoveContext(inventory)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Removes a storage context from an inventory if it exists.
Parameters
-
inventory
Inventory
Inventory to remove a storage context from
ix.storage.RemoveReceiver(client, inventory, bDontRemove)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Removes a storage receiver and removes the context if there are no more receivers.
Parameters
-
client
Player
Player to remove from receivers
-
inventory
Inventory
Inventory with storage context to remove receiver from
-
bDontRemove
boolean
Whether or not to skip removing the storage context if there are no more receivers
ix.storage.Sync(client, inventory)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Synchronizes an inventory with a storage context to the given client.
Parameters
-
client
Player
Player to sync storage for
-
inventory
Inventory
Inventory to sync storage for
Tables
StorageInfoStructure
View source »There are some parameters you can customize when opening an inventory as a storage object with ix.storage.Open.
Fields
-
entity
entity
Entity to "attach" the inventory to. This is used to provide a location for the inventory for things like making sure the player doesn't move too far away from the inventory, etc. This can also be a
player
object.
-
id
number
default: inventory id
The ID of the nventory. This defaults to the inventory passed into
ix.Storage.Open
.
-
name
string
default: "Storage"
Title to display in the UI when the inventory is open.
-
bMultipleUsers
boolean
default: false
Whether or not multiple players are allowed to view this inventory at the same time.
-
searchTime
number
default: 0
How long the player has to wait before the inventory is opened.
-
text
string
default: "@storageSearching"
Text to display to the user while opening the inventory. If prefixed with
"@"
, it will display a language phrase.
-
OnPlayerClose
function
optional
Called when a player who was accessing the inventory has closed it. The argument passed to the callback is the player who closed it.
-
data
table
default: {}
Table of arbitrary data to send to the client when the inventory has been opened.