Consume an item instance from the user's inventory
useItemInstance(item_instance_id, callback)

🚧

Warning

This function should ONLY be used if your game does not have a server for consuming item instances. If your game has a server component, please use the server-side version.

Consuming user item instances

You can consume a limited-use item instance by using the useItemInstance method. This function takes the item instance ID (retrieved using the requestUserItemList function) and a callback function to be called when the operation is completed.

Name

Type

Description

item_instance_id

Integer

The item instance ID to be consumed

callback

Function

A callback function to be called with the results of the operation

The callback function is passed a single object with the following fields:

Name

Type

Description

success

Boolean

A flag indicating whether or not the operation was successful

id

Integer

The ID of the item instance that was consumed

Example: Consume an item from the player's inventory

kongregate.mtx.useItemInstance(12345, onUseResult);

function onUseResult(result:Object):void {
  trace("Item use result successful: " + result.success);
}
kongregate.mtx.useItemInstance(12345, onUseResult);

function onUseResult(result) {
  console.log("Item use result successful: " + result.success);
}