question

stevenbalderrama avatar image
stevenbalderrama asked

Retrieving Player Title data Private

Hello,

I am trying to find a way to retrieve player data private, specifically, I have it working where it has Stored it successfully to Playfab... However bringing it down I was using link:https://docs.microsoft.com/en-us/rest/api/playfab/client/player-data-management/getuserdata?view=playfab-rest#getuserdataresult

, or using the method "GetTitleDataRequest", to trying to retrieve it, is not working or not doing it right... also trying to do the same for Player Statistics... here is my code below, hopefully its a simple misunderstanding or wrong method or field?

Player Data Title private retrieval method:

    public void ClientGetTitleData()
    {
        PlayFabClientAPI.GetTitleData(new GetTitleDataRequest(),
            result =>
            {


                if (result.Data.Keys == null)
                {
                    Debug.Log("No Player Name");
                }
                else
                {
                    Debug.Log("PlayerName: " +  result.Data["PlayerName"]);
                }
            },
            error =>
            {
                Debug.Log("Got error getting titleData:");
                Debug.Log(error.GenerateErrorReport());
            }
        );
    }


also below is the Player statistics:

    void OnDataReceived(GetPlayerStatisticsResult result)
    {
        if(result.CustomData != null)
        {
            foreach(var eachstat in result.Statistics)
            {
                if(eachstat.StatisticName.Equals("PlayerGender"))
                {
                    P_Gender_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerSkinColor"))
                {
                    P_SkinColor_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerHair"))
                {
                    P_HairType_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerHairColor"))
                {
                    P_HairColor_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerShirt"))
                {
                    P_Shirt_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerShirtColor"))
                {
                    P_ShirtColor_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerPants"))
                {
                    P_Pants_Index = eachstat.Value;
                }
                if (eachstat.StatisticName.Equals("PlayerPantsColor"))
                {
                    P_PantsColor_Index = eachstat.Value;
                }
            }
        }
        else
        {
            var randGender = new System.Random();
            int resgender = randGender.Next(0, 2);
            P_Gender_Index = resgender;


            System.Random randSkinColor = new System.Random();
            P_SkinColor_Index = randSkinColor.Next(0, 4);
            System.Random randHairColor = new System.Random();
            P_HairColor_Index = randHairColor.Next(0, 3);


            while (P_SkinColor_Index == P_HairColor_Index)
                P_HairColor_Index = randHairColor.Next(0, 3);
        }
    }

thank you in advanced :)

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

stevenbalderrama avatar image stevenbalderrama commented ·

So good news, i did get the player statistics working, able to read stats now... However still trying to Read Player Title Data private... any idea?

0 Likes 0 ·

1 Answer

·
stevenbalderrama avatar image
stevenbalderrama answered

finally got it to work, so something similar to the get player stats method, here is the code example below, hope it comes in handy for someone:

public void PlayerData(GetUserDataResult result) { if(result.Data != null) { foreach(var playerData in result.Data) { if (playerData.Key == "PlayerName") { IF_DisplayName.text = playerData.Value.Value; } } } } void GetPlayerName() { PlayFabClientAPI.GetUserData( new GetUserDataRequest(), PlayerData, OnError); } 
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.