I want to get the rank 1 or the high score on google leaderboard, how can I do that?
Look at this API call for GPGS: https://docs.coronalabs.com/plugin/gameNetwork-google/request.html#load-scores
Then you just take the first item in the list.
Rob
local playerName -- CALLBACK LISTENER WHICH RETURNS THE PLAYERS' ID/ALIAS local function loadPlayerData( event ) playerName = event.data[1].alias end -- CALLBACK LISTENER WHICH RETURNS THE LEADERBOARD SCORES local function loadScoresFromLeaderboard( event ) gameNetwork.request( "loadPlayers", { playerIDs = {event.data[1].playerID}, listener = loadPlayerData }) end -- REQUEST THE LEADERBOARD SCORES gameNetwork.request("loadScores", { leaderboard = { category = "LEADERBOARD\_ID", playerScope = "Global", range = {1,10} }, listener = loadScoresFromLeaderboard }) native.showAlert( "Name", playerName, { "OK"} )
Thanks, I manage to load the high score player
then on the code above, I wanted to get the name of that player, but the problem is the variable “playerName” seems to be empty, I don’t know why, it should have the value of event.data[1].alias
local function loadPlayerData( event ) playerName = event.data[1].alias end
I think the problem is, the above function has never been called by this function:
local function loadScoresFromLeaderboard( event ) gameNetwork.request( "loadPlayers", { playerIDs = {event.data[1].playerID}, listener = loadPlayerData }) end
I’m not sure why is that, any help please please please
Look at this API call for GPGS: https://docs.coronalabs.com/plugin/gameNetwork-google/request.html#load-scores
Then you just take the first item in the list.
Rob
local playerName -- CALLBACK LISTENER WHICH RETURNS THE PLAYERS' ID/ALIAS local function loadPlayerData( event ) playerName = event.data[1].alias end -- CALLBACK LISTENER WHICH RETURNS THE LEADERBOARD SCORES local function loadScoresFromLeaderboard( event ) gameNetwork.request( "loadPlayers", { playerIDs = {event.data[1].playerID}, listener = loadPlayerData }) end -- REQUEST THE LEADERBOARD SCORES gameNetwork.request("loadScores", { leaderboard = { category = "LEADERBOARD\_ID", playerScope = "Global", range = {1,10} }, listener = loadScoresFromLeaderboard }) native.showAlert( "Name", playerName, { "OK"} )
Thanks, I manage to load the high score player
then on the code above, I wanted to get the name of that player, but the problem is the variable “playerName” seems to be empty, I don’t know why, it should have the value of event.data[1].alias
local function loadPlayerData( event ) playerName = event.data[1].alias end
I think the problem is, the above function has never been called by this function:
local function loadScoresFromLeaderboard( event ) gameNetwork.request( "loadPlayers", { playerIDs = {event.data[1].playerID}, listener = loadPlayerData }) end
I’m not sure why is that, any help please please please