Google Play leaderboards

Is there a way to implement Google Play Leaderboards on my game in GDevelop? :thinking:

3 Likes

I am trying this too. Especially as I want to store how many times someone has won a game as score (adding point for wins and subtracting them for lost and disconnected games). That means the person needs to be authenticated. Google play game services in combination with its leader board would do that perfectly without having to create my own database in sql together with php script to access it. If any one knows about a tutorial to integrate google leaderboard in gdevelop it would be very welcome. I am still working to better the game elements online and its coming along nicely but google integration would be great as a next step. All help as usual is greatly appreciated.

Sadly, google play isn’t easy to integrate as it is only accessible via Android system libraries, and cordova, the technology we use to run games there, doesn’t allow direct access to those. We would need a plugin, but there exist only one and it is very outdated and doesn’t work with the newest API levels required by google play :confused:

You can try to use firebase instead, there is an integration in GDevelop and it allows to do authentication and having a database easily. It also comes with other stuff, for example you could easily add analytics to see how many players play the game and other insight in how they interact with it.

1 Like

Thanks you will have a look into fire base. Happy reading :D)

1 Like

I have authentication running in Firebase thanks to your great tutorial. Now I will have to look into creating a leaderboard. Would you recommend using Cloud FireStore or the Realtime Database? I am not quit sure yet what the differences are.

For example If someone disconnects from the game I want him to get minus points in the leaderboard (this would encourage players to stay in the game as there is nothing more annoying than having to play against a quitter). These minus points will have to be given by the other player ofcourse whom has the UID of the competitor. It would therefore be more of a ranking system than a leaderboard.

Also could I store the username and password on a mobile device? As far as I saw that would be a problem with Gdevelop for now too. Thanks for your help again.

Generally, I would recommend Cloud Firestone as it is most of the time faster, easier to secure and more reliable. Realtime Database is technically easier as it allows structuring data as JSON, so basically it literally stores a structure variable, where Cloud Firestone needs structuring in collections and documents (basically, the database is a list of collections, a directory of documents which are structure variables, and documents themselves can have collections).

This sounds dangerous as on firebase, if a user can access one variable they can do whatever they want with it if you don’t have perfect validation rules. If you can remove score from another user, you can probably falsify the score of any user.

That’s a bad idea. If it is saved there, it is probably extractable and users probably wouldn’t appreciate their password from being leaked especially since many persons reuse the same passwords across sites. Unless you log out, firebase should keep the user logged in, so no need to worry about this.

1 Like

That was very helpfull. I did more reading and I believe I now understand it better. Indeed FireStore is easier and the best way while the whole authentication process is automatic login already. Fantastic it works.

But when it comes to writing a document in the fire store I am stuck. I cannot seem to write a document to it as you do in the example on the tutorial site. GDevelop 5

This is my collection

These are the new rules

And alike the old rules:

It does not write any data to the firestore. This is my code in Gdevelop

My object is to save the players name in a FireStore collection called EmailUserName so that when the person comes back I can read the Players name again. But at this moment the preview simply freezes. Any thoughts on what I am doing wrong?

I

Because you cannot do the authentication in the preview.

No you can. The authentication works in preview. Without the write it just goes through and I see the user account created in Firebase (See pics above). The preview also works in the example in the link. The write also works in the preview in the example link.

Okay I meant the provider auth.

You can isolate the problem.
does it work with if true rules?
the event will be executed?
works with hardcodet UID?
try to write a field, it will automatically write the document

1 Like

I will try. I also discovered that display name is already in authentication and thus I save it directly with set user display name. That makes far more sense off course. I am a total noob when it comes to Firebase so I am learning as I go. (try to write a field, it will automatically write the document) That is actually a good idea I will try them now one by one see if that solves it. Because I still will have to write to the leaderboard. But one issue is now down. I am begining to see light at the end of the tunnel :smiley:

this ruleset

rules_version = ‘2’;
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}

together with writing only a field works :sunny: . So I think I broke trough the problem. Ofcourse it was me. I do not like rules :D. Thanks you for the support. Great help

1 Like

What events were you using? You should be able to write more than just 1 field :thinking:

The one toggled disabled WORKS. Then the document is created. But if I do it as the one that is not disabled it freezes the program.

I changed the rules to allow read, write, create, update, delete: if true But to no avail.

:thinking: I think you can only write structure variables, not string variables.

1 Like

Doh off course. Its the field in the document. And all the while I am looking at your code and thinking (O thats nice so with the structures and all) not making the link to the Firebase document its structure self. Everything works now. I was simply to excited to calmly look and thoroughly investigate it. Fantastic. Thanks so much arthuro555 again. You helped me enormously.

1 Like