• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android achievement_load_leaderboard

H

HansMills

Guest
I am trying to do the same thing without success. I noticed the help file in GameMaker Studio 2 has this note about the achievement_load_leaderboard function.

NOTE: this function does not work on the Android platform.

The help file has an example how to use this command on an Android platform:
if os_type == os_android
{
achievement_load_leaderboard("CgkIs9_51u0PEAIQBw", 1, 100, achievement_filter_friends_only);
}

But the Social Asynchronous Event call back event is never triggered.
 

chirpy

Member
I took a look into GooglePlayServicesExtension.java and it seems to me there's no implementation for showing a single leaderboard by its id.
I was able to add one following Google's official guide though; there are 2 steps:

(1) Add a new method to GooglePlayServicesExtension.java (under extensions\GooglePlayServicesExtension\AndroidSource\Java); I called it gps_show_leaderboard, with content copied from onShowGSLeaderboards and mixed with official guide's code.
Code:
 public void gps_show_leaderboard(String id)
    {
  if (isSignedIn()) {
   RunnerActivity.CurrentActivity.startActivityForResult(Games.Leaderboards.getLeaderboardIntent(getApiClient(), id), RC_GPS_ACTIVITY);
  }
  else {
   (new AlertDialog.Builder(RunnerActivity.CurrentActivity))
      .setTitle("Leaderboard Not Available")
      .setMessage("You can't view the leaderboard because you are not signed in.")
      .setNeutralButton("OK", null)
      .show();
  }
 }
(2) Add this function to GooglePlayServicesExtension -> Resources/File/
GooglePlayServicesExtension.ext -> Properties -> Functions

Name: gps_show_leaderboard (or whatever you wanted to call in gml)
External Name: gps_show_leaderboard (or whatever you named it in GooglePlayServicesExtension.java)
ReturnType: double
Argument: string

:rolleyes:
Note: I am no pro to Java, nor Android, nor GM:S2, just happened to be working on achievements recently, so please correct me if I did something wrong (e.g. What is RC_GPS_ACTIVITY ..?).

Unfortunately my mac died a couple days ago so I can't look into the iOS counterpart right now. :( Do you guys mean achievement_load_leaderboard is working perfectly under iOS?
 
Last edited:
H

HansMills

Guest
Thanks Chirpy! That worked for me.

RC_GPS_ACTIVITY is an integer used for statuses.
RC_RESOLVE = 5000
RC_UNUSED = 5001
RC_GPS_ACTIVITY = 5011
 
S

Siracher

Guest
ah thanks guys, I missed the updates on this thread!
Will try this as well :)
 

RyanC

Member
If this can show a specific scoreboard then surly there must be a way to adjust the ext to actual pull the scoreboard data too?

Google does state this is possible for Android, and actually encourages it.
 
P

Pano

Guest
achievement_show_leaderboards() load a screen with all leaderboards of my ID
what you mean exactly? Currently I have a single leaderboard;

if I added a second leaderboard, achievement_show_leaderboards() would show both of them?
 
S

Siracher

Guest
yes it should. I get a selection of leaderboards to choose when I click in my game on the leaderboard button. It's good if you have several leaderboards but most games have only one and then it's just an unnecessary step.
 
Top