cityrp.inventory
Contains a bunch of stuff to do with inventories.
TODO: Better description
Functions
cityrp.inventory.AddToWorld(item)
View source »Transfers an item to the world inventory
Parameters
-
item
Item
The item to add
cityrp.inventory.Create(owner, size, invType, callback)
View source »Creates a new inventory. This is for creating a brand new inventory that does not already exist in the DB, to load see cityrp.inventory.Load
Parameters
-
owner
Player or string
The owner of the inventory if there is a player owner. It accepts either a player object or a steamID64 string.
-
size
number
The size of the inventory.
-
invType
string
The type of this new inventory, useful for the hook OnInventoryCreated to do custom stuff. Make sure the name isn't already taken by another inventory type.
-
callback
function
optional
The callback to call when the inventory is created.
cityrp.inventory.CreateInf(invType)
View source »Creates an infinite inventory that will save, intended for world inventories (do not use for players etc...) This will create a DB entry for the inventory, to prevent an ID conflict as only 0 is reserved for world Items for infinite inventories will not automatically load in, these inventories exist just to be able to set an ID for an item.
Parameters
-
invType
string The name/type of this inventory, this is not unique and is intended for easier identification
cityrp.inventory.CreateInternal(id, owner, size, data)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Documentation for this section is incomplete and needs expanding.
Parameters
-
id
any
-
owner
string or integer
-
size
number
-
data
table
optional
Returns
-
unknown
cityrp.inventory.FindOfflinePlayerInventory(sid64, type, callback)
View source »Find an offline player's inventory ID, able to specify type. Player doesn't actually have to be offline, but it's intended for that as otherwise you don't need this? This does not load the inventory, it simply gets the ID. Will return the first found result if multiple exist for whatever reason
Parameters
-
sid64
string
Player SID64
-
type
string
Inventory type to get
-
callback
optional )
Callback to run when the query is complete, will return the inventory ID as first arg, will be nil if not found.
cityrp.inventory.Get(id)
View source »Gets an inventory by its ID.
Parameters
-
id
integer
The ID of the inventory.
Returns
-
Inventory or nil The inventory.
cityrp.inventory.GetWorldInv()
View source »Gets the world inventory
Returns
-
Inventory The world inventory
cityrp.inventory.Load(id, callback)
View source »Loads an inventory and all items within it into memory from the database.
Parameters
-
id
number
The ID of the inventory.
-
callback
function
optional
The callback to call when the inventory and all its items is loaded. Callback is passed to cityrp.item.LoadFromInv, will return the inventory as first arg.
cityrp.inventory.OpenMenu(client, inv1, inv2, force, readOnly)
View source »Opens the inventory (or inventory trasnfer) menu for a client.
Parameters
-
client
Player
Client to open the menu for
-
inv1
Inventory
Source (primary) inventory to open
-
inv2
optional
Optional second target inventory, will do transfer if specified
-
force
optional
Ignore permission checks
-
readOnly
optional
Open the inventory in read-only mode, please note this does not restrict anything serverside!
cityrp.inventory.ProcessConversionRefunds(client, item, amount)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Used to convert or process some items being converted from the legacy system to the new This is useful if an item needs to be changed in some way or refunded for the new system
Parameters
-
client
Player
The player to process refunds for
-
item
any
The item to process
-
amount
any
The amount of the item to process
cityrp.inventory.SendSnapshot(client, id, openMenu)
View source »Network an inventory "snapshot" to a client, this is a read-only one-time sync of the inventory.
Parameters
-
client
Player
The client to network the inventory to.
-
id
integer
The ID of the inventory to network.
-
openMenu
boolean
optional
Whether to open the inventory menu after the snapshot is sent.