question

Max Guernsey, III avatar image
Max Guernsey, III asked

What is the best way to determine if a catalog item is consumable?

In the economy editor, there is a dropdown like this.

However, in the C# SDK, I am having difficulty finding a corresponding flag (or null object or whatever).

I've currently settled on this utra-hacky-feeling algorithm:

static bool IsConsumable(CatalogItem FromServer)
{
  return 
    FromServer.Consumable?.UsageCount != null ||
    FromServer.Consumable?.UsagePeriod != null ||
    FromServer.Consumable?.UsagePeriodGroup != null ;
}

As they say on the late-night infomercials: "There must be a better way!"

What is it?

In-Game Economy
fjsr6.png (4.4 KiB)
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

·
Citrus Yan avatar image
Citrus Yan answered

Yes, indeed, currently there is no “decent” way to do this. PlayFab always returns the “Consumable” field, whether a item is defined as consumable or not. You can use custom tags to identify whether a item is consumable or not, or make a request regarding this, sorry for the inconvenience.

PS: your method can be simplified as the following because an item with no UsageCount & UsagePeriod specified will automatically turn into durable :

return 
FromServer.Consumable?.UsageCount
!= null || FromServer.Consumable?.UsagePeriod != null;
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.