question

Cricket_FeVR avatar image
Cricket_FeVR asked

How do I access the player inventory from server side using unity? Can someone post the code?

How can I access the player's inventory from server side using unity? I have the code for accessing it from the client side. Can someone please post for the server side?

apisPlayer Inventory
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

·
JayZuo avatar image
JayZuo answered

You can use Server API to do this. For your requirement, it would be GetUserInventory. With this method, you will need to provide the PlayFabId of the player you want to access. For example

PlayFabServerAPI.GetUserInventory(new PlayFab.ServerModels.GetUserInventoryRequest { PlayFabId = {PlayFabId} },
    result =>
    {
        result.Inventory.ForEach(item => Debug.Log(item.ItemInstanceId + " : " + item.DisplayName));
    },
    error => { Debug.LogError(error.GenerateErrorReport()); });
3 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.

Cricket_FeVR avatar image Cricket_FeVR commented ·

How do I return items of particular item class?

0 Likes 0 ·
JayZuo avatar image JayZuo ♦ Cricket_FeVR commented ·

What you you want to return? You may use LINQ or write a foreach loop to find the items you want.

0 Likes 0 ·
Cricket_FeVR avatar image Cricket_FeVR JayZuo ♦ commented ·

this function prints all items of the inventory for that playfab ID. I want to print certain items from the inventory i.e items of particular class or tags.

0 Likes 0 ·

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.