question

diyan avatar image
diyan asked

Granting items with ModifyItemUses incorrectly generates player_consumed_item playstream event,Granting items with ModifyItemUses incorrectly generates player_consumed_item event

If I give a positive amount of items to a user with ModifyItemUses API, the Playstream event that is generated is com.playfab.player_consumed_item. Here is the generated response when I added 2 uses of an item:

 {
     "EventName": "player_consumed_item",
     "ItemId": "snowman",
     "CatalogVersion": "Main Catalog",
     "ItemInstanceId": "11EC7374EC1A57DC",
     "PreviousUsesRemaining": 1,
     "UsesRemaining": 3,
     "Class": "boost",
     "EventNamespace": "com.playfab",
     "EntityType": "player",
     "Source": "PlayFab",
     "TitleId": "C15DC",
     "EntityId": "F60A005E5D8D7DB1",
     "EventId": "1cf9b969c9cb4ec2a85c9f640fb9537c",
     "SourceType": "BackEnd",
     "Timestamp": "2023-01-11T15:17:48.8336047Z",
     "History": null,
     "CustomTags": null,
     "Reserved": null,
     "PlayFabEnvironment": {
         "Vertical": "master",
         "Cloud": "main",
         "Application": "mainserver",
         "Commit": "aab0da2"
     }
 }

As you can see, the event is player_consumed_item, but I'm adding items, not removing them. Note that UsesRemaining = 3 and PreviousUsesRemaining = 1. The user consumed "-2" items! This is wrong. Either ModifyItemUses must not generate playstream events, or the resulting event must be either player_consumed_item or player_inventory_item_added depending on whether items are being added or removed.

,If I give a positive amount of items to a user with ModifyItemUses API, the Playstream event that is generated is com.playfab.player_consumed_item. Here is an example of the generated response when I added 2 uses of an item, as seen on Playstream monitor:

 {
     "EventName": "player_consumed_item",
     "ItemId": "snowman",
     "CatalogVersion": "Main Catalog",
     "ItemInstanceId": "11EC7374EC1A57DC",
     "PreviousUsesRemaining": 1,
     "UsesRemaining": 3,
     "Class": "boost",
     "EventNamespace": "com.playfab",
     "EntityType": "player",
     "Source": "PlayFab",
     "TitleId": "C15DC",
     "EntityId": "F60A005E5D8D7DB1",
     "EventId": "1cf9b969c9cb4ec2a85c9f640fb9537c",
     "SourceType": "BackEnd",
     "Timestamp": "2023-01-11T15:17:48.8336047Z",
     "History": null,
     "CustomTags": null,
     "Reserved": null,
     "PlayFabEnvironment": {
         "Vertical": "master",
         "Cloud": "main",
         "Application": "mainserver",
         "Commit": "aab0da2"
     }
 }

As you can see, the event is player_consumed_item, but I'm adding items, not removing them. Note that UsesRemaining = 3 and PreviousUsesRemaining = 1. Turns out the user consumed "-2" items! This is wrong. Either ModifyItemUses must not generate playstream events, or the resulting event must be either player_consumed_item or player_inventory_item_added depending on whether items are added or removed.

Player Inventory
2 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.

diyan avatar image diyan commented ·

If somebody asks why everything is doubled in my post, the same forum bug happened to me as described here: https://community.playfab.com/idea/5789/community-forums-ability-to-edit-feature-requests.html Your forum is full of bugs. Fix it!

0 Likes 0 ·
Simon Cui avatar image Simon Cui commented ·

I was doing some tests for your case, sorry for the inconvenience.

0 Likes 0 ·

1 Answer

·
Simon Cui avatar image
Simon Cui answered

The ModifyItemUses API is used to modify the number of remaining uses of a player's inventory item, where you can refer to Player Item Management - Modify Item Uses - REST API (PlayFab Server) | Microsoft Learn. Hence if you add 2 uses to an item which has 1 PreviousUsesRemaining, the UsesRemaining will be 3.

As for the PlayStream Event player_consumed_item, it is triggered when a player consumes an item from their inventory. The name of this event do cause some confusion when adding uses to an item. Thanks for your suggestion, we are trying our best to improve PlayFab system and provide better experience.

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.