question

Aimbot Studio avatar image
Aimbot Studio asked

Is there a way to get user inventory specific to a catalog?

I have more than 1 catalog in the playfab inventory. each catalog has its items. i want to get user inventory specifically to a catalog. I want to know is this possible? if possible then how to do it and if not any wayaround to solve it.

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

Aimbot Studio avatar image Aimbot Studio commented ·
public void GetUserInventory()
    {
        var request = new GetUserInventoryRequest();
        PlayFabClientAPI.GetUserInventory(request, result =>
        {
            Debug.Log("UserInventory");
            foreach (var item in result.Inventory)
            {
                
            }


            DataManager.Instance.itemList = DataManager.Instance.MapInventory(result.Inventory);
            DataManager.Instance.MapInventoryCards();
        },
        error =>
        {


        });
    }

0 Likes 0 ·

1 Answer

·
Made Wang avatar image
Made Wang answered

You can use GetUserInventory to get the current user's inventory, traverse the items in the inventory in the callback, and determine whether the CatalogVersion of each item is the same as the catalog you want.

If your platform is Unity, you can refer to the code below.

public void GetUserInventory()
    {
        List<ItemInstance> itemList = new List<ItemInstance>();


        PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(),
            (result) =>
            {
                foreach (var item in result.Inventory)
                {
                    //Debug.Log(item.DisplayName + ":" + item.CatalogVersion);
                    if (item.CatalogVersion == "Your CatalogVersion/CatalogName")
                    {
                        itemList.Add(item);
                    }
                }


                DataManager.Instance.itemList = DataManager.Instance.MapInventory(itemList);
                DataManager.Instance.MapInventoryCards();
            },
            (error) =>
            {
                Debug.LogError(error.GenerateErrorReport());
            });
    }
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.