CityRP Documentation Repository

cityrp.inventory

Client-side inventory management and display.

Functions

Clientcityrp.inventory.canFit(size) → booleanSource ☍

Check if a certain size will fit in the local player's inventory.

Parameters

  • sizenumberThe size to check fitting.

Returns

  1. booleanIf the given size will fit.
Clientcityrp.inventory.GetAmount(item, meta) → numberSource ☍

Get the amount of an item (optionally matching specific metadata) held by the local player.

Parameters

  • itemstringThe item id to look up.
  • metastring?The metadata key to match, normalized via cityrp.itemmeta when available.

Returns

  1. numberThe amount held, 0 if none.
Clientcityrp.inventory.getMaximumSpace() → numberSource ☍

Get the maximum inventory space of the local player.

Returns

  1. numberInventory size.
Clientcityrp.inventory.getSize() → numberSource ☍

Get the currently used inventory space of the local player.

Returns

  1. numberInventory use.
Servercityrp.inventory.LoadInventory(player)Source ☍

Loads a player's inventory from the database into player.cityrp._Inventory.

Parameters

  • playerPlayerThe player to load an inventory for.
Servercityrp.inventory.sizeAlert(player, size) → booleanSource ☍

Checks whether adding size would bring a player within 5 units of their inventory limit.

Parameters

  • playerPlayerThe player to check.
  • sizenumberThe size being added.

Returns

  1. booleanWhether the player is near their inventory limit.
Servercityrp.inventory.sizeAlertFull(player, size) → booleanSource ☍

Checks whether a player's inventory is completely full.

Parameters

  • playerPlayerThe player to check.
  • sizenumberThe size being added; sizes below 1 are ignored (never reported as full).

Returns

  1. booleanWhether the player's inventory is at maximum capacity.
Servercityrp.inventory.update(ply, unique, amount, meta, force) → boolean, string?Source ☍

Updates a player's inventory with a given amount of an item, persisting the change to the database and networking it to the player.

Parameters

  • plyPlayerThe player whose inventory is being updated.
  • uniquestringThe item class to give.
  • amountnumberThe number of items to give (may be negative to remove).
  • metaanyThe meta data for the stack being updated.
  • forceboolean?Whether to bypass inventory size limits.

Returns

  1. 1booleanWhether the inventory was updated.
  2. 2string?Why the update failed, if unsuccessful.
Servercityrp.inventory.updateMeta(ply, unique, amount, meta, newmeta) → boolean, string?Source ☍

Moves a quantity of an item stack from one meta key to another in a player's inventory, persisting the change to the database and networking it to the player.

Parameters

  • plyPlayerThe player whose inventory is being updated.
  • uniquestringThe item class to change.
  • amountnumberThe number of items to move.
  • metaanyThe meta data for the item(s) to change.
  • newmetaanyThe meta data to change the item(s) to.

Returns

  1. 1booleanWhether the update succeeded.
  2. 2string?Why the update failed, if unsuccessful.
Servercityrp.player.convertInventoryString(data) → table<string, number>, table<string, number>Source ☍

Converts a legacy semicolon-delimited inventory string into inventory/invalid-inventory tables. should no longer be used

Deprecated

This function is deprecated and may be removed in a future version.

Legacy format, kept only for reading old data; new code stores inventories directly.

Parameters

  • datastringThe semicolon-delimited "item: amount; ..." string to parse.

Returns

  1. 1table<string, number>Amounts keyed by valid item unique.
  2. 2table<string, number>Amounts keyed by unrecognized item unique.
Servercityrp.player.getInventoryString(player) → stringSource ☍

Serializes a player's inventory (and any invalid items carried over from loading) into the legacy semicolon-delimited string format, for use in logs. used by logs still

Parameters

  • playerPlayerThe player whose inventory is being serialized.

Returns

  1. stringThe serialized inventory string.

Tables

Clientcityrp.inventorySource ☍
Clientcityrp.inventory.storedSource ☍

Items currently stored on the client.