question

mitu avatar image
mitu asked

ConsumeItem not finding items in Character Inventory?,ConsumeItem not finding Instance ID for items in Character Inventory, only Player Inventory?

Hi,

I'm trying to run Consumeitem for items in a character inventory (not player inventory). I'm using the following code:

PlayFabClientAPI.ConsumeItem(new ConsumeItemRequest() { ConsumeCount = 1, ItemInstanceId = playFabInstanceID },
result =>
    {
        //success code here

    }, error =>
    {
        Debug.Log("Error reducing health:");
        Debug.Log(error);
    });

However, I am getting an Item Not Found error -- even though I can see via a GetCharacterInventory() that the item is correct.

I discovered that this code does work if I try to run it on an item in the player inventory instead. Is there a way I can run Consumeitem for items in a character's inventory?! The documentation seems to suggest that this should work. :(

,

Hi,

I'm trying to use ConsumeItem, via the following code, for items in a Character's Inventory:

PlayFabClientAPI.ConsumeItem(new ConsumeItemRequest() { ConsumeCount = 1, ItemInstanceId = playFabInstanceID },
result =>
    {
	//successful code here<br>
    }, error =>
    {
        Debug.Log("Error reducing health:");
        Debug.Log(error);
    });

However, I'm getting "Item not found" errors whenever I run this, even though a GetCharacterInventory() shows that the ID is correct. After much consternation, I discovered that this error ONLY happens for items in the Character Inventory, but it DOES work for items in the Player Inventory.

The documentation seems to suggest this should work for items in a Character Inventory. What should I be doing here?

Player InventoryCharacter Data
1 comment
10 |1200

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

mitu avatar image mitu commented ·

(Apologies for the weird double post, it seemed like my first post got eaten so I had to retype it then it magically reappeared!)

0 Likes 0 ·

1 Answer

·
mitu avatar image
mitu answered

Ah, I realize I needed to pass in CharacterId as a first parameter for this to work! Leaving this here either for mods to delete or for someone else who may run into this.

PlayFabClientAPI.ConsumeItem(new ConsumeItemRequest() { CharacterId = currentCharacterID , ConsumeCount = 1, ItemInstanceId = playFabInstanceID },
    result =>
    {
	//success code here
    }, error =>
    {
        Debug.Log("Error reducing health:");
        Debug.Log(error);
    });
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.