I wish to get a particular value after a player logs in via Facebook. I am aware that GetPlayerStatistics() is the correct method to do so, but how do I go about storing this value? I am using Unity by the way and I wish to store it in a UI text.
I wish to get a particular value after a player logs in via Facebook. I am aware that GetPlayerStatistics() is the correct method to do so, but how do I go about storing this value? I am using Unity by the way and I wish to store it in a UI text.
I got away by doing something like this:
private void OnGetPlayerStatisticsSuccess(GetPlayerStatisticsResult result){
Debug.Log ("Success on getting Player's score.");
Dictionary<string, int> playerStatistics = new Dictionary<string, int>();
foreach (var each in result.Statistics) {
playerStatistics[each.StatisticName] = each.Value;
}
string s = playerStatistics ["Ranking"].ToString ();
}
but if you don't mind please explain why the previous error occured. I still don't quite understand the structure of GetPlayerStatisticsResult. :(
Hi,
@Brendan
I got the following errors while I tried implementing the methods:
The best overloaded method match for `System.Collections.Generic.List<PlayFab.ClientModels.StatisticValue>.this[int]' has some invalid arguments
Argument `#1' cannot convert `string' expression to type `int'
Script below:
private void GetPlayerStatistics(){
GetPlayerStatistics Request request=new GetPlayerStatisticsRequest();
PlayFabClientAPI.GetPlayerStatistics(request, OnGetPlayerStatisticsSuccess, PlayFabErrorCallBack);
}
private void OnGetPlayerStatisticsSuccess(GetPlayerStatisticsResult result){
Debug.Log("Success on getting Player's score.");
string s=result.Statistics["Ranking"].Value.ToString();
}
appreciate your help on this.
Actually, GetPlayerStatistics (and the write equivalent - UpdatePlayerStatistics) is for numeric values. Please see this tutorial on statistics and leaderboards for more on that topic: https://api.playfab.com/docs/tutorials/landing-players/player-statistics.
If you want to store and retrieve non-numeric values in the player account, you'll want to use one of the forms of player data available: https://api.playfab.com/docs/tutorials/landing-players/using-player-data
2 People are following this question.