Leaderboard Widget

Managing Leaderboard

App42 Leaderboard allows game developers to save score and manage their leaderboard using the scoreboard service. One can query for the average or the highest score for users in the game/level. One can also view average/highest scorer in a given game/level. It also records and provides rankings of users against a given group of users(For example Facebook friends) in a game/level.

To get started with the leaderboard, you have to first create a game/level inside your AppHQ console. Here a Game can be logically considered as a different game level inside your app. One can have as many games/levels in a given App42 app. Here are the steps to create a Game/Level from the console.

bullet Login to AppHQ console

bullet Go to Gaming -> Games -> Select Your App

bullet Click on Add Game button as shown in below image and fill all the required fields and submit to save the game

AddGameLayout

Once your game/level is created you are ready to use leaderboard services as explained below.

Save User Score

Once your game/level is created inside the AppHQ, you can save user score on the App42 cloud using following snippet. It requires user name, game name and his score as input parameters. Once the user score is saved it will return you a unique score id to edit this record if required.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game/level_name>"; 
String userName = "Nick";
BigDecimal gameScore = new BigDecimal(3500);
scoreBoardService.saveUserScore(gameName,userName,gameScore,new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	for(int i = 0;i<game.getScoreList().size();i++)
	{
		System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
		System.out.println("score is : " + game.getScoreList().get(i).getValue());
		System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
		System.out.println("Created On is  :"+game.getScoreList().get(i).getCreatedOn());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
NSString *gameName = @"<Enter_your_game/level_name>";
NSString *userName = @"Nick";
double gameScore = 3500;
Game *game = [scoreBoardService saveUserScore:gameName gameUserName:userName gameScore:gameScore]; 
NSLog(@"gameName is = %@" game.name);
NSMutableArray *scoreList = game.scoreList;
for(Score *score in scoreList)
{
	NSLog(@"User Name is = %@",score.userName);
	NSLog(@"Value is = %f",score.value); 
	NSLog(@"scoreId is = %f",score.scoreId); 
}
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game/level_name>";
String userName = "Nick";
double gameScore = 3500;
scoreBoardService.SaveUserScore(gameName,userName,gameScore,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message" + exception);  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}  
}
String gameName = "<Enter_your_game/level_name>";
String userName = "Nick";
double gameScore = 3500;
Game game = scoreBoardService.saveUserScore(gameName,userName,gameScore); 
System.out.println("gameName is " + game.getName());
Vector scoreList =  game.getScoreList();
for(int i=0;i < scoreList.size();i++)
{ 
	Game.Score score = (Game.Score)  scoreList.elementAt(i);
	System.out.println("userName is " + score.getUserName());
    System.out.println("value is " + score.getValue());
    System.out.println("scoreId is " + score.getScoreId());
}
var gameName = "<Enter_your_game/level_name>",
userName = "Nick",
gameScore = 3500,
result ;  
scoreBoardService.saveUserScore(gameName,userName,gameScore,{  
	success: function(object) 
	{  
		var game = JSON.parse(object);  
		result = game.app42.response.games.game;
		console.log("gameName is : " + result.name)
		var scoreList = result.scores.score;
		console.log("userName is : " + scoreList.userName)
		console.log("scoreId is : " + scoreList.scoreId)
		console.log("value is : " + scoreList.value)
	},  
	error: function(error) {  
	}  
}); 
String gameName = "<Enter_your_game/level_name>";
String userName = "Nick";
BigDecimal gameScore = new BigDecimal(3500);
Game game = scoreBoardService.saveUserScore(gameName,userName,gameScore); 
System.out.println("gameName is " + game.getName());
for(int i = 0;i<game.getScoreList().size();i++)
{
	System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
	System.out.println("score is : " + game.getScoreList().get(i).getValue());
	System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
}
String gameName = "<Enter_your_game/level_name>";
String userName = "Nick";
double gameScore = 3500;
scoreBoardService.SaveUserScore(gameName, userName, gameScore, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game/level_name>";
String userName = "Nick";
double gameScore = 3500;
Game game = scoreBoardService.SaveUserScore(gameName,userName,gameScore); 
Console.WriteLine("gameName is " + game.GetName());  
for(int i = 0;i<game.GetScoreList().Count;i++)
{
	Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
	Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
	Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
}
$gameName = "<Enter_your_game/level_name>";
$userName = "Nick";
$gameScore = 3500;
$game = $scoreBoardService->saveUserScore($gameName,$userName,$gameScore);
print_r("gameName is " . $game->getName());
$scoreList = $game->getScoreList();
foreach( $scoreList as $score )
{
print_r("User Name is " . $score->getUserName());
print_r("Value is " . $score->getValue());
}
game_name = "<Enter_your_game/level_name>";
game_user_name = "Nick"; 
game_score = 400000;						
game = score_board_service.save_user_score(game_name, game_user_name, game_score);
puts "gameName is #{game.name}";
score_list = Array.new();
score_list = game.score_list();
for score in score_list do
  puts "userName is #{score.userName}";
  puts "value is #{score.value}";
end
json_response = game.to_s();
var gameName:String = "<Enter_your_game/level_name>";	
var userName:String = "userName";
var gameScore:int = 40000;		
scoreBoardService.saveUserScore(gameName,userName,gameScore, new callback());  
public class callback implements App42CallBack  
{  
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception : " + excption);  
	}  
	public function onSuccess(response:Object):void  
	{  
		var scoreClass:Score = new Score();
		var game:Game   = Game(res);
		trace("gameName is : " + game.getName());
		trace("username is :  " + Score(gameResponse.getScoreList()[0]).getUserName());
		trace("value is : " + Score(gameResponse.getScoreList()[0]).getValue());
		trace("scoreId is :  " + Score(gameResponse.getScoreList()[0]).getScoreId());
	}  
}  
Coming Soon 

Generating Global Leaderboard for Top Rankers

Once the user score is saved, you can fetch global top ranks on the leaderboard by passing your game name and max result(Top 10/20 etc) option as shown below in snippet. This will include the all time highest score of individual users on the leaderboard.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game/level_name>";
int max = 10;
scoreBoardService.getTopNRankers(gameName,max, new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	for(int i = 0;i<game.getScoreList().size();i++)
	{
		System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
		System.out.println("score is : " + game.getScoreList().get(i).getValue());
		System.out.println("Created On is  :"+game.getScoreList().get(i).getCreatedOn());
		System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
NSString *gameName = @"<Enter_your_game/level_name>";
int max = 10;
Game *game = [scoreBoardService getTopNRankers:gameName max:max]; 
NSLog(@"gameName is = %@" game.gameName);
NSMutableArray *scoreList = game.scoreList;
for(Score *score in scoreList)
{
	NSLog(@"User Name is = %@",score.userName);
	NSLog(@"Value is = %f",score.value); 
	NSLog(@"scoreId is = %f",score.scoreId); 
}
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game/level_name>";
int max = 10;
scoreBoardService.GetTopNRankers(gameName,max,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}  
}
String gameName = "<Enter_your_game/level_name>";
int max = 10;
Game game = scoreBoardService.getTopNRankers(gameName,max); 
System.out.println("gameName is " + game.getName());
Vector scoreList =  game.getScoreList();
for(int i=0;i < scoreList.size();i++)
{ 
	Game.Score score = (Game.Score)  scoreList.elementAt(i);
	System.out.println("userName is " + score.getUserName());
    System.out.println("value is " + score.getValue());
    System.out.println("scoreId is " + score.getScoreId());
}
var gameName = "<Enter_your_game/level_name>",
max = 10,
result ;  
scoreBoardService.getTopNRankers(gameName,max,{  
	success: function(object) 
	{  
		var game = JSON.parse(object);  
		result = game.app42.response.games.game;
		console.log("gameName is : " + result.name)
		var scoreList = result.scores.score;
		for(var i=0;i<scoreList.length;i++)
		{
			console.log("userName is : " + scoreList[i].userName)
			console.log("scoreId is : " + scoreList[i].scoreId)
			console.log("value is : " + scoreList[i].value)
		}
	},  
	error: function(error) {  
	}  
}); 
String gameName = "<Enter_your_game/level_name>";
int max = 10;
Game game = scoreBoardService.getTopNRankers(gameName,max); 
System.out.println("gameName is " + game.getName());
for(int i = 0;i<game.getScoreList().size();i++)
{
	System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
	System.out.println("score is : " + game.getScoreList().get(i).getValue());
	System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
}
String gameName = "<Enter_your_game/level_name>";
int max = 10;
scoreBoardService.GetTopNRankers(gameName, max, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game/level_name>";
int max = 10;
Game game = scoreBoardService.GetTopNRankers(gameName,max); 
Console.WriteLine("gameName is " + game.GetName());  
for(int i = 0;i<game.GetScoreList().Count;i++)
	{
		Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
		Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
		Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
	}
$gameName = "<Enter_your_game/level_name>";
$max = 10;
$game = $scoreBoardService->getTopNRankers($gameName,$max);
print_r("gameName is " . $game->getName());
$scoreList = $game->getScoreList();
foreach( $scoreList as $score )
{
print_r("User Name is " . $score->getUserName());
print_r("Value is " . $score->getValue());
}
Coming Soon
var gameName:String = "<Enter_your_game/level_name>";	
var max:int = 5;
scoreBoardService.getTopNRankers(gameName,max, new callback());  
public class callback implements App42CallBack  
{  
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var game:Game = Game(response);  
		trace("response is : " + game);
	}  
}  
Coming Soon 

Generating Leaderboard For Top Rankers In Given User Group

Once the user score is saved, you can fetch top ranking entries on the leaderboard in given group by passing your game name and user array list option as shown below in snippet. This will return a leaderboard of passed list of user set.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game/level_name>";
ArrayList<String> userList = new ArrayList<String>();
userList.add("Nick");
userList.add("John");
userList.add("Balley");
scoreBoardService.getTopNRankersByGroup(gameName,userList,new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	for(int i = 0;i<game.getScoreList().size();i++)
	{
		System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
		System.out.println("score is : " + game.getScoreList().get(i).getValue());
		System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
		System.out.println("Created On is  :"+game.getScoreList().get(i).getCreatedOn());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
NSString *gameName = @"<Enter_your_game/level_name>";
NSArray *userList = [[NSArray alloc]initWithObjects:@"Nick", nil];
Game *game = [scoreBoardService getTopNRankersByGroup:gameName userList:userList]; 
NSLog(@"gameName is = %@" game.gameName);
NSMutableArray *scoreList = game.scoreList;
for(Score *score in scoreList)
{
	NSLog(@"User Name is = %@",score.userName);
	NSLog(@"Value is = %f",score.value); 
	NSLog(@"scoreId is = %f",score.scoreId); 
}
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game/level_name>";
IList<String> userList = new IList<String>();
userList.Add("Nick");
userList.Add("John");
userList.Add("Balley");
scoreBoardService.getTopNRankersByGroup(gameName,userList,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}  
}
String gameName = "<Enter_your_game/level_name>";
Vector userList = new Vector();
userList.addElement("Nick");
userList.addElement("John");
userList.addElement("Balley");
Game game = scoreBoardService.getTopNRankersByGroup(gameName,userList); 
System.out.println("gameName is " + game.getName());
Vector scoreList =  game.getScoreList();
for(int i=0;i < scoreList.size();i++)
{ 
	Game.Score score = (Game.Score)  scoreList.elementAt(i);
	System.out.println("userName is " + score.getUserName());
    System.out.println("value is " + score.getValue());
    System.out.println("scoreId is " + score.getScoreId());
}
var gameName = "<Enter_your_game/level_name>";
var userList = new Array();
userList.push("Nick");
userList.push("John");
userList.push("Balley");
var result ;  
scoreBoardService.getTopNRankersByGroup(gameName,userList,{  
	success: function(object)
	{  
		var game = JSON.parse(object);  
		result = game.app42.response.games.game;
		console.log("gameName is : " + result.name)
		var scoreList = result.scores.score;
		for(var i=0;i<scoreList.length;i++)
		{
			console.log("userName is : " + scoreList[i].userName)
			console.log("scoreId is : " + scoreList[i].scoreId)
			console.log("value is : " + scoreList[i].value)
		}
	},  
	error: function(error) {  
	}  
}); 
String gameName = "<Enter_your_game/level_name>";
ArrayList<String> userList = new ArrayList<String>();
userList.add("Nick");
userList.add("John");
userList.add("Balley");
Game game = scoreBoardService.getTopNRankersByGroup(gameName,userList); 
System.out.println("gameName is " + game.getName());
for(int i = 0;i<game.getScoreList().size();i++)
{
	System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
	System.out.println("score is : " + game.getScoreList().get(i).getValue());
	System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
}
String gameName = "<Enter_your_game/level_name>";
IList<String> userList = new List<String>();
userList.Add("Nick");
userList.Add("John");
userList.Add("Balley");
scoreBoardService.getTopNRankersByGroup(gameName,userList, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game/level_name>";
IList<String> userList = new List<String>();
userList.Add("Nick");
userList.Add("John");
userList.Add("Balley");
Game game = scoreBoardService.getTopNRankersByGroup(gameName,userList); 
Console.WriteLine("gameName is " + game.GetName());  
for(int i = 0;i<game.GetScoreList().Count;i++)
	{
		Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
		Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
		Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
	}
$gameName = "<Enter_your_game/level_name>";
$userList = array();
array_push($userList, "Nick");
array_push($userList, "John");
array_push($userList, "Balley");
$game = $scoreBoardService->getTopNRankersByGroup($gameName,$userList);
print_r("gameName is " . $game->getName());
$scoreList = $game->getScoreList();
foreach( $scoreList as $score )
{
print_r("User Name is " . $score->getUserName());
print_r("Value is " . $score->getValue());
}
Coming Soon
 
var gameName:String = "<Enter_your_game/level_name>";	
var userList:Array = new Array();
userList.push("Nick");
userList.push("John");
userList.push("Balley");
scoreBoardService.getTopNRankersByGroup(gameName,userList, new callback());  
public class callback implements App42CallBack  
{ 
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var game:Game = Game(response);  
		trace("response is : " + game);
	}  
}  
Coming Soon 

Generating Leaderboard of Top Rankers from Facebook Friends

If you are using Facebook in your app for user management and login, you can generate a leaderboard of the users Facebook friends using App42 API as shown below. Prerequisite for generating the Facebook leaderboard is that the username should be used as the Facebook user id while saving the score of user. See How to Save User Score. Also, a valid access token of app user should be passed in the below code to generate a Facebook friends leaderboard.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String gameName = "<Enter_your_game/level_name>";  
String accessToken = "<Enter_user's_facebook_access_token>";  
int max = 2;  
scoreBoardService.getTopNRankersFromFacebook(gameName, accessToken, max, new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	System.out.println("Game Name is : "+game.getName());
	for(int i=0;i<game.getScoreList().size();i++)
	{
		System.out.println("UserName is:"+game.getScoreList().get(i).getUserName());
		System.out.println("Value is"+game.getScoreList().get(i).getValue());
		System.out.println("Craeted On is: "+game.getScoreList().get(i).getCreatedOn());
		System.out.println("ScoreId is: "+game.getScoreList().get(i).getValue());
		System.out.println("id is :"+ game.getScoreList().get(i).getFacebookProfile().getId());
		System.out.println("friend  name is "+ game.getScoreList().get(i).getFacebookProfile().getName());
		System.out.println("picture url is "+ game.getScoreList().get(i).getFacebookProfile().getPicture());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
}); 
Coming Soon
String gameName = "<Enter_your_game_name>";  
String accessToken = "<Enter_user's_facebook_access_token>";
int max = 2;
scoreBoardService.GetTopNRankersFromFacebook(gameName, accessToken, max, new Callback());  
public class Callback : App42Callback  
{  
	public void OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message : " + exception);  
	}  
	public void OnSuccess(Object response)  
	{  
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score value is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
			Console.WriteLine("Created On : " + game.GetScoreList()[i].GetCreatedOn());
			Console.WriteLine("Facebook id is : " + game.GetScoreList()[i].GetFacebookProfile().GetId());
			Console.WriteLine("Facebook name is : " + game.GetScoreList()[i].GetFacebookProfile().GetName());
			Console.WriteLine("Facebook picture is : " + game.GetScoreList()[i].GetFacebookProfile().GetPicture());
		}
	}  
String gameName = "<Enter_your_game_name>";  
String accessToken = "<Enter Facebook Access Token>";  
int max = 2;  
Game score = scoreBoardService.getTopNRankersFromFacebook(gameName, accessToken, max);
for(int i=0;i<score.getScoreList().size();i++)
{
	System.out.println("UserName is:"+ ((Game.Score)score.getScoreList().elementAt(i)).getUserName());
	System.out.println("Value is"+score.((Game.Score)score.getScoreList().elementAt(i)).getValue());
	System.out.println("ScoreId is: "+ ((Game.Score)score.getScoreList().elementAt(i)).getScoreId());
	System.out.println("Created On is: "+((Game.Score)score.getScoreList().elementAt(i)).getCreatedOn());
	System.out.println("Facebook id is :"+ ((Game.Score)score.getScoreList().elementAt(i)).getFacebookProfile().getId());
	System.out.println("Facebook friend  name is "+ ((Game.Score)score.getScoreList().elementAt(i)).getFacebookProfile().getName());
	System.out.println("Facebook picture url is "+ ((Game.Score)score.getScoreList().elementAt(i)).getFacebookProfile().getPicture());
} 

Coming Soon
String gameName = "<Enter_your_game_name>";  
String accessToken = "<Enter Facebook Access Token>";  
int max = 2;  
Game game = scoreBoardService.getTopNRankersFromFacebook(gameName, accessToken, max);
System.out.println("Game Name is : "+game.getName());
for(int i=0;i<game.getScoreList().size();i++)
{
	System.out.println("UserName is:"+game.getScoreList().get(i).getUserName());
	System.out.println("Value is"+game.getScoreList().get(i).getValue());
	System.out.println("Craeted On is: "+game.getScoreList().get(i).getCreatedOn());
	System.out.println("ScoreId is: "+game.getScoreList().get(i).getValue());
	System.out.println("id is :"+ game.getScoreList().get(i).getFacebookProfile().getId());
	System.out.println("friend  name is "+ game.getScoreList().get(i).getFacebookProfile().getName());
	System.out.println("picture url is "+ game.getScoreList().get(i).getFacebookProfile().getPicture());
}  
String gameName = "<Enter_your_game_name>";  
String accessToken = "<Enter Facebook Access Token>";
int max = 2;  
App42Log.SetDebug(true);		//Print output in your editor console
scoreBoardService.GetTopNRankersFromFacebook(gameName, accessToken, max, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i < game.GetScoreList().Count; i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score value is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
			App42Log.Console("Created On : " + game.GetScoreList()[i].GetCreatedOn());
			App42Log.Console("Facebook id is : " + game.GetScoreList()[i].GetFacebookProfile().GetId());
			App42Log.Console("Facebook name is : " + game.GetScoreList()[i].GetFacebookProfile().GetName());
			App42Log.Console("Facebook picture is : " + game.GetScoreList()[i].GetFacebookProfile().GetPicture());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game_name>";  
String accessToken = "<Enter Facebook Access Token>";
int max = 2;  
Game game = scoreBoardService.GetTopNRankersFromFacebook(gameName, accessToken, max);
for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score value is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
			Console.WriteLine("Created On : " + game.GetScoreList()[i].GetCreatedOn());
			Console.WriteLine("Facebook id is : " + game.GetScoreList()[i].GetFacebookProfile().GetId());
			Console.WriteLine("Facebook name is : " + game.GetScoreList()[i].GetFacebookProfile().GetName());
			Console.WriteLine("Facebook picture is : " + game.GetScoreList()[i].GetFacebookProfile().GetPicture());
		}
Coming Soon
Coming Soon
 
var gameName:String="<Enter_your_game_name>";
var accessToken:String="<Enter Facebook Access Token>";
var max:int= 5;
scoreBoardService.getTopNRankersFromFacebook(gameName, accessToken , max , new callback());
class callback implements App42CallBack
{
    public function onSuccess(response:Object):void
	{
		var facebookProfile:FacebookProfile;
		if(response is Game)
		{
			var score:Score = new Score();
			var gameResponse:Game   = Game(response);
			trace("GameName is : " + gameResponse.getName());
			for(var l:int =0;l<gameResponse.getScoreList().length;l++)
			{
				score = Score(gameResponse.getScoreList()[l]);
				trace("username  " +score.getUserName());
				trace("value   " +score.getValue());				
				trace("scoreId  " +score.getScoreId());
				trace("created on"+score.getCreatedOn());	
				facebookProfile = FacebookProfile(score.getFacebookList()[l]);
				trace("FB Id is : " + facebookProfile.getId());						
				trace("FB Name is : " + facebookProfile.getName());				
				trace("FB Picture is : " + facebookProfile.getPicture());
			}
		}
	}
	public function onException(excption:App42Exception):void
	{
		outputField.text += "" + excption;
	}
}
Coming Soon 

Editing User Score

If you want to edit the score of an individual user, you can use score id of the saved score to edit it as shown in below snippet. This requires new score and score id to be passed as input parameter.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
String scoreId = "scoreId";
BigDecimal gameScore = new BigDecimal(3500);
scoreBoardService.editScoreValueById(scoreId,gameScore,new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	for(int i = 0;i<game.getScoreList().size();i++)
	{
		System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
		System.out.println("score is : " + game.getScoreList().get(i).getValue());
		System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
		System.out.println("Created On is  :"+game.getScoreList().get(i).getCreatedOn());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
}); 
NSString *scoreId = @"scoreId";
double gameScore = 3500;
Game *game = [scoreBoardService editScoreValueById:scoreId gameScore:gameScore]; 
NSLog(@"gameName is  = %@" game.name);
NSMutableArray *scoreList = game.scoreList;
for(Score *score in scoreList)
{
	NSLog(@"User Name is = %@",score.userName);
	NSLog(@"Value is = %f",score.value); 
	NSLog(@"scoreId is = %f",score.scoreId); 
}
public class Callback : App42Callback  
{  
String scoreId = "scoreId";
double gameScore = 3500;
scoreBoardService.EditScoreValueById(scoreId,gameScore,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}  
}
String scoreId = "scoreId";
double gameScore = 3500;
Game game = scoreBoardService.editScoreValueById(scoreId,gameScore); 
System.out.println("gameName is  " + game.getName());
Vector scoreList =  game.getScoreList();
for(int i=0;i < scoreList.size();i++)
{ 
	Game.Score score = (Game.Score)  scoreList.elementAt(i);
	System.out.println("userName is " + score.getUserName());
    System.out.println("value is " + score.getValue());
    System.out.println("scoreId is " + score.getScoreId());
}
var scoreId = "scoreId",
gameScore = 3500,
result ;  
scoreBoardService.editScoreValueById(scoreId,gameScore,{  
	success: function(object) 
	{  
		var game = JSON.parse(object);  
		result = game.app42.response.games.game;
		console.log("gameName is : " + result.name)
		var scoreList = result.scores.score;
		console.log("userName is : " + scoreList.userName)
		console.log("scoreId is : " + scoreList.scoreId)
		console.log("value is : " + scoreList.value)
	},  
	error: function(error) {  
	}  
}); 
String scoreId = "scoreId";
BigDecimal gameScore = new BigDecimal(3500);
Game game = scoreBoardService.editScoreValueById(scoreId,gameScore); 
System.out.println("gameName is  " + game.getName());
for(int i = 0;i<game.getScoreList().size();i++)
{
	System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
	System.out.println("score is : " + game.getScoreList().get(i).getValue());
	System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
}
String scoreId = "scoreId";
double gameScore = 3500;
scoreBoardService.EditScoreValueById(scoreId, gameScore, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String scoreId = "scoreId";
double gameScore = 3500;
Game game = scoreBoardService.EditScoreValueById(scoreId,gameScore); 
Console.WriteLine("gameName is  " + game.GetName());  
for(int i = 0;i<game.GetScoreList().Count;i++)
	{
		Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
		Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
		Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
	}
$scoreId = "scoreId";
$gameScore = 3500;
$game = $scoreBoardService->editScoreValueById($scoreId,$gameScore);
print_r("gameName is  " . $game->getName());
$scoreList = $game->getScoreList();
foreach( $scoreList as $score )
{
print_r("User Name is " . $score->getUserName());
print_r("Value is " . $score->getValue());
}
Coming Soon
var scoreId:String = "scoreId";	
var gameScore:int = 2000;	
scoreBoardService.editScoreValueById(scoreId,gameScore, new callback());  
public class callback implements App42CallBack  
{  
	public function onException(excption:App42Exception):void  
	{  
		trace("Exception Message");  
	}  
	public function onSuccess(response:Object):void  
	{  
		var game:Game = Game(response);  
		trace("response is : " + game);
	}  
}  
Coming Soon 

Generating Leaderboard From Buddy Group

If you are using buddy management in your application, you can create a leaderboard among the buddy group of a user as shown below.

  • create User Api for Android
  • create User Api for J2ME
  • create User Api for Android
  • create User Api for iOS
  • create User Api for Java
  • create User Api for .NET
  • create User Api for Unity
  • create User Api for Ruby
  • create User Api for Rest
  •  create User Api for WP7/WP8
  • create User Api for Flash
 
String gameName = "<Enter_your_game/level_name>";
String userName = "userName";
String ownerName = "ownerName";
String groupName = "groupName";
Game game = scoreBoardService.getTopRankersFromBuddyGroup(gameName, userName, ownerName, groupName,new App42CallBack() {
public void onSuccess(Object response) 
{
	Game game = (Game)response;
	for(int i = 0;i<game.getScoreList().size();i++)
	{
		System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
		System.out.println("score is : " + game.getScoreList().get(i).getValue());
		System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
		System.out.println("Created On is  :"+game.getScoreList().get(i).getCreatedOn());
	}
}
public void onException(Exception ex) 
{
	System.out.println("Exception Message"+ex.getMessage());
}
});
coming Soon					                                             
public class Callback : App42Callback  
{  
String gameName = "<Enter_your_game/level_name>";
String userName = "userName";
String ownerName = "ownerName";
String groupName = "groupName";
Game game = scoreBoardService.getTopRankersFromBuddyGroup(gameName, userName,
				ownerName, groupName,this);  
	void App42Callback.OnException(App42Exception exception)  
	{  
		Console.WriteLine("Exception Message");  
	}  
	void App42Callback.OnSuccess(Object response)  
	{  
		Game game = (Game) response;     
		Console.WriteLine("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
			Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
			Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}  
}
String gameName = "gameName" ;
String buddyName = "buddyName";
String ownerName = "ownerName" ;
String groupName = "groupName";
Game game = scoreBoardService.getTopRankersFromBuddyGroup(gameName, buddyName, ownerName, groupName);
System.out.println("GameName is "  + game.getName());
Vector scoreList =  game.getScoreList();
for(int i=0;i < scoreList.size();i++)
{ 
	Game.Score score = (Game.Score)  scoreList.elementAt(i);
	System.out.println("userName is " + score.getUserName());
    System.out.println("value is " + score.getValue());
    System.out.println("scoreId is " + score.getScoreId());
}         
var gameName = "<Enter_your_game/level_name>",
userName = "Nick",
ownerName = "ownerName",
groupName = "groupName",
var result ;  
scoreBoard.getTopRankersFromBuddyGroup(gameName,userName,ownerName,groupName,{  
	success: function(object) 
	{  
		var game = JSON.parse(object);  
		result = game.app42.response.games.game;
		console.log("gameName is : " + result.name)
		var scoreList = result.scores.score;
		for(var i=0;i<scoreList.length;i++)
		{
			console.log("userName is : " + scoreList[i].userName)
			console.log("scoreId is : " + scoreList[i].scoreId)
			console.log("value is : " + scoreList[i].value)
		}
	},  
	error: function(error) {  
	}  
}); 
 String gameName = "<Enter_your_game/level_name>";
String userName = "userName";
String ownerName = "ownerName";
String groupName = "groupName";
Game game = scoreBoardService.getTopRankersFromBuddyGroup(gameName, userName, ownerName, groupName);
System.out.println(game.getScoreList().get(0).getUserName());	
for(int i = 0;i<game.getScoreList().size();i++)
{
	System.out.println("userName is : " + game.getScoreList().get(i).getUserName());
	System.out.println("score is : " + game.getScoreList().get(i).getValue());
	System.out.println("scoreId is : " + game.getScoreList().get(i).getScoreId());
}		
String gameName = "<Enter_your_game/level_name>";
String userName = "userName";
String ownerName = "ownerName";
String groupName = "groupName";
scoreBoardService.GetTopRankersFromBuddyGroup(gameName, userName, ownerName, groupName, new UnityCallBack()); 
public class UnityCallBack : App42CallBack
{
	public void OnSuccess(object response)
	{
		Game game = (Game) response;     
		App42Log.Console("gameName is " + game.GetName()); 
		for(int i = 0;i<game.GetScoreList().Count;i++)
		{
			App42Log.Console("userName is : " + game.GetScoreList()[i].GetUserName());
			App42Log.Console("score is : " + game.GetScoreList()[i].GetValue());
			App42Log.Console("scoreId is : " + game.GetScoreList()[i].GetScoreId());
		}
	}
	public void OnException(Exception e)
	{
		App42Log.Console("Exception : " + e);
	}
}
String gameName = "<Enter_your_game/level_name>";
String userName = "userName";
String ownerName = "ownerName";
String groupName = "groupName";
Game game = scoreBoardService.GetTopRankersFromBuddyGroup(gameName, userName, ownerName, groupName);
for(int i = 0;i<game.GetScoreList().Count;i++)
{
	Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
	Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
	Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
}
Coming Soon
Coming Soon
Coming Soon
Coming Soon

More Details?

bullet Go To Scoreboard API Usage Guide