When I click the button to show my local leaderboard my highscore always shows and it always shows "global rank: " but it does not always show the actual rank. My code is below. any help would be great thanks!
if (GUI.Button (new Rect (820, 180, 220, 100), " Local \n Scores", GameFont2)) {
// Clearing Data From Response Box.
success = "";
personalBest = "";
globalRanking = "";
UnityLeaderboardAsteroidAttack.success = "";
UnityLeaderboardAsteroidAttack.playerRank = "";
UnityLeaderboardAsteroidAttack.playerName = "";
UnityLeaderboardAsteroidAttack.playerScore = "";
UnityLeaderboardAsteroidAttack.errorLable = "";
UnityLeaderboardAsteroidAttack.box = "";
UnityLeaderboardAsteroidAttack.columnName = "";
if (txt_max == 0) {
return;
}
scoreBoardService = App42API.BuildScoreBoardService (); // Initializing scoreBoardService.
int max = txt_max; // Maximum Number Of TOP RANKERS.
string userName = LogIn.UserName;
if (userName == "")
{
errorLable = "You can't see your scores without signing in!";
}
//Getting Top Scorers , By Using App42 Scoreboard Service.
//Method Name->GetTopNRankers(gameName, max);
//Param->gameName(Name Of The Game, Which Is Created By You In AppHQ.)
//Param->max(Provide Max Number "N" Of Scorers.)
//Param->Callback(callback for success/exception.);
//scoreBoardService.GetUserRanking (cons.gameName, userName, this);
scoreBoardService.GetHighestScoreByUser(cons.gameName, userName, this);
scoreBoardService.GetUserRanking (cons.gameName, userName, this);
leaderBoardButton = true;
//UnityLeaderboardAsteroidAttack.leaderBoardButton = false;
localButton = true;
// Reset matrix
GUI.matrix = Matrix4x4.identity;
}
}
//=======================================================================================
//---------------------------ON-SUCCESS OF APP42CALLBACK.--------------------------------------
//=======================================================================================
/// <summary>
/// Raises the success event.
/// </summary>
/// <param name="response">Response.</param>
public void OnSuccess (object response)
{
var nxtLine = System.Environment.NewLine; //Use this whenever i need to print something On Next Line.
Game gameResponseObj = (Game)response;
if (leaderBoardButton) {
leaderBoardButton = false;
IList<Game.Score> topRankersList = gameResponseObj.GetScoreList ();
if (topRankersList.Count > 0) {
for (int i = 0; i < gameResponseObj.GetScoreList().Count; i++) {
double highestScoreValue = gameResponseObj.GetScoreList () [i].GetValue ();
personalBest = "Highest Score: " + personalBest + highestScoreValue.ToString () + nxtLine; //Getting Player Name.
}
for(int i = 0;i<gameResponseObj.GetScoreList().Count;i++) {
string GlobalRank = gameResponseObj.GetScoreList () [i].GetRank ();
globalRanking = "Global Ranking: " + GlobalRank;
}
}
}
}