Sign In Register

How can we help you today?

Start a new topic
Answered

Leaderbord serious problem

 Hi there , i have a serious problem , why i can't see my players name in my leader board ? , i see they score and name are blank , my game is running on playStore now, user keep send feed back about this , when i check 

i can't see their name , only my name. sorry for my English. see the leaderboard. nom = name it's french . space reserved for the name are blank. i'm using facebook for user registration.  



Best Answer

I believe I have solved it for you. 

You seem to have players that registered using their device. When this method of auth is used. DisplayName is left undefined. It is the players displayName that shows in the leaderboardDataRequest ( userName is protected as it is account related). 

There is no data associated with your players displayNames so they show as blank. (displayNames are referred to as userNames in the leaderboarddata response message, I'll see if we can get that fixed)

To remedy this you have a couple of options: 

1: Use registrationRequest rather than deviceAuthenticationRequest (this will prompt the player to enter a user AND display name) from now on. 


2: prompt existing users to enter a displayName for their account in the authentication response or deviceAuthenticationRequest cloud code. You can do this through using Cloud Code-> Resposnses -> authenticationResponse  or CloudCode-> requests-> deviceAuntenticationRequest and then issue a spark request using the following cloud code. 


var request = new SparkRequests.ChangeUserDetailsRequest();


request.displayName = yourPlayersInputString; 


3. social connect requests should sync the display name also. I noticed your code seems to use some of the older Facebook sdk stuff. So try using my singleton : https://pastee.org/udmhx


If your current player base is for test purposes, just start over, use registrationRequest. If not, try solution 2 or 3.


Does this give you the insight you needed? If you need additional help please let me know.


Regards Patrick.  

    


Hi certil, 


To answer you I need some more information:

 

1.How are you registering players? Is it By using their device, or by use of the RegisterPlayer request? 


2.What request are you using to get this data? 


3.Have you tested it in the test harness? Does it work in the test harness?   (The problem may lie with your code, at your end.)


4. What game engine (if any) are you using? 

With this information I can better answer you. 


Regards Patrick. 


   


 Face book registration, and Here's a sample found in tutorial i used :

 

using UnityEngine;
using System.Collections;
using Facebook;
using GameSparks.Api.Requests;

public class LoginManager : MonoBehaviour {
	public GameObject ContButton;

	public void Awake()
	{
		if (!FB.IsInitialized)
		{
			FB.Init(FacebookLogin);
			ContButton.SetActive (true );
		}
		else
		{
			FacebookLogin();
		}
	}

	public void FacebookLogin()
	{
		if (!FB.IsLoggedIn)
		{
			FB.Login("", GameSparksLogin);
		}
	}

	public void GameSparksLogin(FBResult result)
	{
		if (FB.IsLoggedIn)
		{
		
			new FacebookConnectRequest().SetAccessToken(FB.AccessToken).Send((response) =>
			{
				if (response.HasErrors)
				{
					Debug.Log("Something failed when connectiong with Facebook");

				}
				else
				{
					Debug.Log("GameSparks Facebook Login Successful");
					ContButton.SetActive (true );

				}
			});

		}
	}
}

 Its work, player registered correctly, i see their name on my dashboard, but not display on my leader-board.



here's the leaderborad Code:


 

using UnityEngine;
using System.Collections;

using UnityEngine.UI;

using System;


public class Leaderboard_SampleScript : MonoBehaviour 

{
	
public Text scoreInput, outputData;

public GameObject highScorePopup;

	
void Awake () 
	
{
		
GameSparks.Api.Messages.NewHighScoreMessage.Listener += HighScoreMessageHandler;
 // assign the New High Score message
	
}

	
void HighScoreMessageHandler (GameSparks.Api.Messages.NewHighScoreMessage _message)
	
{
		
Debug.Log ("NEW HIGH SCORE \n "+_message.LeaderboardName);
		
highScorePopup.GetComponent<Popup>().CallPopup(_message);

	}

	
public void PostScoreBttn()
	
{
		Debug.Log ("Posting Score To Leaderboard...");
		
new GameSparks.Api.Requests.LogEventRequest ()
			
.SetEventKey("SUBMIT_SCORE")
			
.SetEventAttribute("SCORE", scoreInput.text)
			
.Send ((response) => {

					if(!response.HasErrors)
					{
						Debug.Log("Score Posted Sucessfully...");
					}
					else
					{
						Debug.Log("Error Posting Score...");
					}
		});
	}

	public void GetLeaderboard()
	{
		Debug.Log ("Fetching Leaderboard Data...");

		new GameSparks.Api.Requests.LeaderboardDataRequest ()
			.SetLeaderboardShortCode ("HIGHSCORE_LEADERBOARD")
			.SetEntryCount(25) // we need to parse this text input, since the entry count only takes long
			.Send ((response) => {

					if(!response.HasErrors)
					{
						Debug.Log("Found Leaderboard Data...");
						outputData.text = System.String.Empty; // first clear all the data from the output
						foreach(GameSparks.Api.Responses.LeaderboardDataResponse._LeaderboardData entry in response.Data) // iterate through the leaderboard data
						{
							int rank = (int)entry.Rank; // we can get the rank directly
							string playerName = entry.UserName;
							string score = entry.JSONData["SCORE"].ToString(); // we need to get the key, in order to get the score
							
outputData.text += rank+"   Nom: "+playerName+"        Point: "+score +"\n"; // addd the score to the output text
						}
					}
					else
					{
						Debug.Log("Error Retrieving Leaderboard Data...");
					}

		});
	}
}

 

 

Answer

I believe I have solved it for you. 

You seem to have players that registered using their device. When this method of auth is used. DisplayName is left undefined. It is the players displayName that shows in the leaderboardDataRequest ( userName is protected as it is account related). 

There is no data associated with your players displayNames so they show as blank. (displayNames are referred to as userNames in the leaderboarddata response message, I'll see if we can get that fixed)

To remedy this you have a couple of options: 

1: Use registrationRequest rather than deviceAuthenticationRequest (this will prompt the player to enter a user AND display name) from now on. 


2: prompt existing users to enter a displayName for their account in the authentication response or deviceAuthenticationRequest cloud code. You can do this through using Cloud Code-> Resposnses -> authenticationResponse  or CloudCode-> requests-> deviceAuntenticationRequest and then issue a spark request using the following cloud code. 


var request = new SparkRequests.ChangeUserDetailsRequest();


request.displayName = yourPlayersInputString; 


3. social connect requests should sync the display name also. I noticed your code seems to use some of the older Facebook sdk stuff. So try using my singleton : https://pastee.org/udmhx


If your current player base is for test purposes, just start over, use registrationRequest. If not, try solution 2 or 3.


Does this give you the insight you needed? If you need additional help please let me know.


Regards Patrick.  

    

Login to post a comment