question

George Gilbert avatar image
George Gilbert asked

Login RequestParameters for PlayerStatistics doesn't always return PlayerStatistics

I'm using PlayFabClientAPI.LoginWithCustomID and setting InfoRequestParameters.GetPlayerStatistics = true (along with some other fields GetUserData, GetTitleData and GetUserReadOnlyData) - and most of the time this works fine and I get the player statistics back in the GetPlayerCombinedInfoResultPayload.PlayerStatistics field.

However, occasionally the login result has all the other fields correctly filled in (UserData etc) but the PlayerStatistics payload field is empty (PlayerStatistics.Count == 0). If I run my game 10 times in a row, logging in with exactly the same account / request parameters each time, about once or twice I get no statistics (but get the user data 100% of the time).

It seems very odd that this is non-deterministic. Is this a known bug with login? Should I be getting player statistics after login, rather than at the same time? Or is there something else going on here?

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

·
George Gilbert avatar image
George Gilbert answered

I'm using the UnitySDK - the following c# exhibits the behaviour:

public void Login(string customID)
{
	GetPlayerCombinedInfoRequestParams loginInfoRequestParams = new GetPlayerCombinedInfoRequestParams(); 
	loginInfoRequestParams.GetUserData = true;
	loginInfoRequestParams.GetUserReadOnlyData = true;
	loginInfoRequestParams.GetPlayerStatistics = true;
	loginInfoRequestParams.GetTitleData = true;


	PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest()
	{
		TitleId = PlayFabSettings.TitleId,
		CustomId = customID,
		CreateAccount = false,
		InfoRequestParameters = loginInfoRequestParams
	},
	(loginResult) =>
	{
		// This sometimes returns zero for a user with non-zero statistics set
		Debug.Log(loginResult.InfoResultPayload.PlayerStatistics.Count);


		if (loginResult.InfoResultPayload.PlayerStatistics.Count == 0)
		{
			PlayFabClientAPI.GetPlayerStatistics(new GetPlayerStatisticsRequest()
			{
			},
			(getStatsResult) =>
			{
				// This returns the correct non-zero number
				Debug.Log(getStatsResult.Statistics.Count);
			},
			(error) =>
			{
			});
		}
	},
	(error) =>
	{
	});
}


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

Rick Chen avatar image Rick Chen ♦ commented ·

I cannot reproduce this issue. Could you provide the relevant code snippet for us to troubleshoot? Could you also try calling the API using the Postman and see if you can still reproduce this issue?

0 Likes 0 ·
Rick Chen avatar image Rick Chen ♦ commented ·

I still cannot reproduce this issue. But yes, you can use the GetPlayerStatistics API in case the login API don't return the statistics.

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.