ZEPETO.Multiplay.Inventory
Type | Description |
|---|---|
The error code specifies the reason for the failure of inventory-related requests. | |
Inventory product information. | |
Inventory | Inventory manages operations associated with the player's in-World product inventory. |
InventoryError
enum
The error code specifies the reason for the failure of inventory-related requests.
Name | Value | Description |
|---|---|---|
Unknown | -1 | Error: Unknown error. |
NetworkError | 0 | Error: Errors related to network issues, including disconnections or unstable connections. |
InventoryRecord
interface
Inventory product information.
Properties
Name | Type | Description |
|---|---|---|
productId | string | Product ID. |
quantity | number | Quantity of the product. |
createdAt | Date | Date and time when the product was added to the inventory. |
updatedAt | Date | Date and time when the product information was last updated. |
Inventory
interface
Inventory manages operations associated with the player's in-World product inventory.
Methods
use
use(productId: string, quantity?: number, reason?: string) → Promise<boolean>
Uses an in-World product from the player's inventory. Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
productId | string | ID of the product to use. |
quantity (optional) | number | Quantity of the product to use. Defaults to 1. |
reason (optional) | string | Optionally describes the reason for usage. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
add
add(productId: string, quantity?: number, reason?: string) → Promise<boolean>
Adds an in-World product to the player's inventory. Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
productId | string | ID of the product to add. |
quantity (optional) | number | Quantity of the product to add. Defaults to 1. |
reason (optional) | string | Optionally describes the reason for the addition. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
madd
madd(products: { productId: string; quantity: number; reason?: string }[]) → Promise<boolean>
Adds multiple in-World products to the player's inventory. Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
products | { productId: string; quantity: number; reason?: string }[] | Array of products to add. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
has
has(productId: string) → Promise<boolean>
Checks the existence of an in-World product in the player's inventory.Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
productId | string | ID of the product to check. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating exist (true) or non-exist (false).
get
get(productId: string) → Promise<InventoryRecord | null>
Retrieves an in-World product from the player's inventory. Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
productId | string | ID of the product to retrieve. |
Returns: Promise<InventoryRecord | null> — Promise resolved upon completion, with the retrieved InventoryRecord object.
remove
remove(productId: string) → Promise<boolean>
Removes an in-World product from the player's inventory. Throws InventoryError.
Parameter | Type | Description |
|---|---|---|
productId | string | ID of the product to remove. |
Returns: Promise<boolean> — Promise resolved upon completion, indicating success (true) or failure (false).
list
list() → Promise<InventoryRecord[]>
Retrieves all in-World products from the player's inventory. Throws InventoryError.
Returns: Promise<InventoryRecord[]> — Promise resolved upon completion, with an array of the retrieved InventoryRecord objects.