API Index
Overview
Setup
Initialize
Achievements
Challenges
Leaderboards
Scores
Players
Real-Time Game
Turn-Based Game
 
Before you can use Scores Commands in your game, you must configure Leaderboards in iTunes Connect and the GameKit Plugin must be setup as well as initialized.
 
Scores Commands
Send Score
Get Scores
Get Scores With Players
 

Send Score
Comments: Send Score to Game Center. Note the optional Param table key, context.

Function: (function) send( (string) “score”, (table) { leaderboardID= (string) “com.yourSite.yourGame.leaderboard”, value= (number) 68, (optional key) context= (number) 42, listener= (function) onScoresCallback } )
Param Table Keys:
(string) leaderboardID – A unique Game Center leaderboard identifier string you created for your game on iTunes Connect.
(number) value – A score number value earned by the local player. You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
(number) context (optional key) – A number value used by your game. The context property is stored and returned to your game, but is otherwise ignored by Game Center. It allows your game to associate an arbitrary 64-bit unsigned integer value with the score data reported to Game Center. You decide how this context value is interpreted by your game.
(function) listener – A function to receive callback events.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “success” – GameKit success event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(string) successDescription – GameKit success description string.

 

Get Scores
Comments: Get Game Center Scores. Note the score filters playerScope, timeScope and range to modify your results.

Function: (function) get( (string) “score”, (table) { leaderboardID= (string) “com.yourSite.yourGame.leaderboard”, playerScope= (string) “Global”, timeScope= (string) “AllTime”, range= (table) {(number) 1, (number) 5}, listener= (function) onScoresCallback } )
Param Table Keys:
(string) leaderboardID – A unique Game Center leaderboard identifier string you created for your game on iTunes Connect.
(string) playerScope – A filter string used to get scores for players on Game Center. playerScope=”Global” or playerScope=”FriendsOnly”. “Global” will get all player’s scores and “FriendsOnly” will only get local player’s friends scores.
(string) timeScope – A filter string used to get scores that were posted to Game Center within a specific period of time. timeScope=”Today” or timeScope=”Week” or timeScope=”AllTime”. “Today” will get player scores recorded in the past 24 hours, “Week” will get player scores recorded in the past week, “AllTime” will get player scores recorded for all time.
(table) range – A filter table of minimum and maximum numbers used to get scores within a specific range that were posted to Game Center. range={minimum, maximum}, the minimum range number is 1 and the maximum range number is 100. For example, if you specified a range of {1,10}, you would get the top ten scores from first to tenth.
(function) listener – A function to receive callback events.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “scoreList” – Score list event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) scoresCount – Number of score tables in the scores array.
(array) scores – Array of score tables.
Score Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) leaderboardID – A unique Game Center leaderboard identifier string you created for your game on iTunes Connect.
(number) rank – A position of the player’s score on the Game Center leaderboard with 1 being the best score, 2 being the second best, and so on.
(string) formattedValue – A player’s score as a localized string. You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
(number) value – A score number value earned by the player.
(number) context – A number value used by your game. The context property is stored and returned to your game, but is otherwise ignored by Game Center. It allows your game to associate an arbitrary 64-bit unsigned integer value with the score data reported to Game Center. You decide how this context value is interpreted by your game.
(string) date – A date and time string of when the score was posted to Game Center.

 

Get Scores With Players
Comments: Get Game Center Scores of players with playerIDs.

Function: (function) get( (string) “scoresWithPlayers”, (table) { leaderboardID= (string) “com.yourSite.yourGame.leaderboard”, playerIDs= (table) {(string) “G:2073637149”}, timeScope= (string) “AllTime”, listener= (function) onScoresCallback } )
Param Table Keys:
(string) leaderboardID – A unique Game Center leaderboard identifier string you created for your game on iTunes Connect.
(table) playerIDs – An array of 1 or more playerID strings to get scores for.
(string) timeScope – A filter string used to get scores that were posted to Game Center within a specific period of time. timeScope=”Today” or timeScope=”Week” or timeScope=”AllTime”. “Today” will get player scores recorded in the past 24 hours, “Week” will get player scores recorded in the past week, “AllTime” will get player scores recorded for all time.
(function) listener – A function to receive callback events.
Callback Events:
Event Name: (string) “gameKitLibrary”
Event Type:
(string) “error” – GameKit error event.
(string) “scoreList” – Score list event.
Event Properties:
(number) errorCode – GameKit GKErrorCode number.
(string) errorDescription – GameKit error description string.
(number) scoresCount – Number of score tables in the scores array.
(array) scores – Array of score tables.
Score Table Keys:
(string) playerID – A string assigned by Game Center to uniquely identify a player.
(string) leaderboardID – A unique Game Center leaderboard identifier string you created for your game on iTunes Connect.
(number) rank – A position of the player’s score on the Game Center leaderboard with 1 being the best score, 2 being the second best, and so on.
(string) formattedValue – A player’s score as a localized string. You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
(number) value – A score number value earned by the player.
(number) context – A number value used by your game. The context property is stored and returned to your game, but is otherwise ignored by Game Center. It allows your game to associate an arbitrary 64-bit unsigned integer value with the score data reported to Game Center. You decide how this context value is interpreted by your game.
(string) date – A date and time string of when the score was posted to Game Center.