Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by madsfknudsen · Jul 06, 2019 at 04:33 PM · dataPlayer InventoryCharacter Data

Getting CustomData from specific user inventory items

Trying to get specific custom data from specific items in the local users inventory.

Do not know if I am going at this the wrong way or if it can not be done.

Code:

List<ItemInstance> Items = new List<ItemInstance>();

GetUserInventoryRequest InventoryR = new GetUserInventoryRequest();

PlayFabClientAPI.GetUserInventory(InventoryR,

result => { Items = result.Inventory; },

error => { Debug.Log(error.ErrorMessage); });

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image

Answer by Brandon Phillips · Jul 06, 2019 at 06:31 PM

What errors are you getting?

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by madsfknudsen · Jul 06, 2019 at 07:27 PM

@Brandon Phillips

Error when calling result.Inventory[0].CustomData["HasBeenCreated"].

HasBeenCreated is one of the customdata keys and has a string value of "false".

NullReferenceException: Object reference not set to an instance of an object CharacterCreator.<Start>b__5_2 (PlayFab.ClientModels.GetUserInventoryResult result) (at Assets/Scripts/CharacterCreation/CharacterCreator.cs:50) PlayFab.Internal.PlayFabHttp+<>c__DisplayClass23_0`1[TResult].<_MakeApiCall>b__1 () (at Assets/Extensions/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabHTTP.cs:218) PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) (at Assets/Extensions/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:246) UnityEngine.Debug:LogException(Exception) PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) (at Assets/Extensions/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:250) PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/Extensions/PlayFabSdk/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:189) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brandon Phillips · Jul 07, 2019 at 11:31 AM 0
Share

Try this:

PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(),
        result => {
            Debug.Log (result.ToJson());
        },
        error => {
            Debug.Log ("Error: " + error.GenerateErrorReport());
        }); 

Look through the returned JSON data that gets logged if it's successful, and make sure it is returning the inventory correctly.

avatar image

Answer by SethDu · Jul 08, 2019 at 06:32 AM

According to the error message, there is a high possibility that the instance doesn’t have this property in the Custom Data. To diagnose it, first is to check if the player owns this item instance in the Game Manager. In addition, manually check the custom data of this item instance. Second, in your C# codes, try to use foreach to print out all the needed information.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FranklinChen · Aug 05, 2019 at 09:03 AM 0
Share

Hi @madsfknudsen, any updates?

avatar image

Answer by Evil Twin · Jun 02 at 07:14 PM

The correct answer is that Playfab doesn't return any CustomData with players' inventory items. It's counterintuitive and doesn't make sense right? But there ya go. It's intentionally null :

https://community.playfab.com/questions/3958/empty-custom-data-for-item-instances.html

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    5 People are following this question.

    avatar image avatar image avatar image avatar image avatar image

    Related Questions

    Setting player data through ue4 blueprints 1 Answer

    Playfab Player Data Fields ? 1 Answer

    How do i get the player inventory from javascript? 1 Answer

    Questions on storing a list of strings on PlayFab to be accessed by all users, or similar methods 2 Answers

    How to print custom data with key value pairs of certain items from server side in C#? 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges