question

brendan avatar image
brendan asked

Can stackable non-consumable items still be consumed?

Question from a developer:

I made a number of durable items in my game catalog which are set as stackable. So if I grant the player 20 of a particular item, the item has 20 uses left in inventory. In our game, the item in question can be used in a way that consumes N of that item for an effect. So if, for example, I consume 5, there should be 15 left. Is that possible with durable items, or do I need to make it consumable?

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

So to be clear, you created the item without setting any consumable values, like Usage Count, but set the item as Stackable? That's fine - a stackable item also uses the RemainingUses value in the item instance to state how many there are. In effect, they are very similar to items with a UsageCount, it's just that as you add more of the same item to the player inventory, the RemainingUses increases accordingly. So you can still use the ConsumeItem or ModifyItemUses calls to change the number the player has (RemainingUses).

7 comments
10 |1200

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

mgambrell avatar image mgambrell commented ·

Well, I clicked add my reply, but looks like it's getting registered as an answer. Strike that. Let's do this instead.

ModifyItemUses doesn't work in this scenario:

CloudScriptLog Error : PlayFab API request error : {"api":"/Server/ModifyItemUses","request":{"PlayFabId":"B3E78405F3B73A30","ItemInstanceId":"6EEC1984121FBC49","UsesToAdd":-1},"result":null,"apiError":{"code":400,"status":"BadRequest","error":"InvalidItemProperties","errorCode":1091,"errorMessage":"Item is not consumable.","errorHash":null,"errorDetails":null}}

The item is clearly stackable and durable.

ConsumeItem doesn't work either, but I didn't grab the error message.

0 Likes 0 ·
brendan avatar image brendan mgambrell commented ·

Ah, interesting. This appears to be because the item hasn't actually had a UsesRemaining value added yet, since there's only one in the stack. I'll get a bug filed on this - thanks for calling it to our attention. The way you can fix this for your title now would be to always set a UsesRemaining of 1 on the item in the catalog. Pre-existing items will not be stacked, but you can do that in an OnLogin operation - see this post for more info on that: https://community.playfab.com/questions/3875/stackable-items-arent-consolidated-in-inventory.html

0 Likes 0 ·
mgambrell avatar image mgambrell brendan commented ·

I don't see how to set UsesRemaining on the catalog item. I don't see UsesRemaining in the CatalogItem struct I get from the server (which seems to faithfully track the web UI for catalog management)

0 Likes 0 ·
Show more comments

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.