question

oglazirin avatar image
oglazirin asked

How to only get all ItemID's for all items in Player's inventory

Hi everyone!

My game's client must download every ItemID for every item in Player's inventory. I don't want to call GetUserInventory because it retrieves all the inventory data, which I already have on the client (because for my game I have to download the full item catalog with all the exisitng items anyway). Therefore downloading the full inventory data generates a lot of duplicate traffic, while I only need ItemIDs.

What would be the most efficient way to work around this?

Thank you!

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

·
oglazirin avatar image
oglazirin answered

Figured it out myself! I had to write a CloudScript function that first calls GetUserInventory on the server and then extracts ItemIDs from the result:

handlers.getPlayerInventory = function(args, context)
{
    var playerInventory = server.GetUserInventory(
    {
        PlayFabId: currentPlayerId
    });
        var ItemIDs = [];
    for (var i in playerInventory.Inventory)
    {
        var ItemId = playerInventory.Inventory[i].ItemId;
        ItemIDs.push( { "ItemId" : ItemId } );
    }


    return { ItemIDs : ItemIDs};
}
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.