question

brendan avatar image
brendan asked

Does PlayFab support consumable inventory items?

How can I create consumable items (health packs, etc.) in PlayFab? What about time-based boosts?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The PlayFab inventory system provides two methods by which items can be made consumable - both usage and time-based. Both of these are set up via the Consumable property in the CatalogItem definition for an item.

For the simple case of an item which has a limited number of uses, the UsageCount property can be set to the number of uses that the player is granted as a result of purchasing the item, or having it give as a result of a call to Server/GrantItemsToUsers or Admin/GrantItemsToUsers. Once the number of uses has been consumed (via calls to Client/ConsumeItem), the item will automatically be removed from the user's inventory.

For items which have time-based expiration, the Consumable property UsagePeriod specifies the time (in seconds) the item should persist in the user's inventory. Once the specified time has elapsed, the item will be removed. Note that it is possible to create objects which extend this expiration period: any inventory items sharing the same UsagePeriodGroup will also share an expiration, which is determined by adding each subsequent item's UsagePeriod. So, if an item with a UsagePeriod of 3600 (3600 seconds, or one hour) and a UsagePeriodGroup of "foo" is added to the user inventory, and then another item with a UsagePeriodGroup of "foo" and a UsagePeriod of 7200 (two hours) is added before the first expires, the expiration time for both items would be 3600 seconds from the time when the first item was added, plus an additional 7200 seconds. Once that time has elapsed, and assuming no items are added to the player inventory with a UsagePeriodGroup of "foo", both items would be removed.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.