[SOLVED] Firebase LeaderBoard

Hello,
i am using leaderboard with firebase. I’m testing the new queries syntax.

My base was the example but I wanto to make small changes.
My goals are:

  • each installation is associated to a name (at the first execution I request it and store it locally)
  • Several players can have the same name.
  • I want to see each player name in the leaderboard only one time

To manage it, when I save the name I also generate a unique GUID and store it locally.
In each game, if your personal score is higher than your record: the system store it locally and send it to firebase.

The problem is that every time the player breaks his record, he enters a new record in Firebase
But so your name is repeated n times.

For example
1/1/2021
Mr. Red player
Match score: 50
Leaderboard
1 - Red - 50 pt

2/1/2021
Mr. Yellow player
Score: 150
Leaderboard
1 - Yellow - 150 pt
2 - Red - 50 pt

3/1/2021
Mr. Red player
Score: 350
Leaderboard
1 - Red - 350 pt
2 - Yellow - 150 pt

Follownìing the example, the result is:
Leaderboard
1 - Red - 350 pt
2 - Yellow - 150 pt
3 - Red - 50 pt

What I need is, on Mr. Red’s new record, to update Firebase and not insert a new record into Firebase.

Thanks,
J

If you want each user to have one record, you can instead of adding a document set a document, using as document name the player GUID making sure each player has only one document. You can still put the readable name in the document and display that so that several users can have a name. You can add firebase authentication to give each user unique ID and to write security rules that prevent other users from overwriting your scores.

1 Like

Thanks !!!
You are a genius
It’s works

1 Like

Hi, I used the same example. For me add document to firestore works but write document doesn’t work. I’m using the rule same as of example. Do I need to change anything in the rule?

It works. Asap (tomorrow or the day after I prepare the example).

1 Like

Variable Player:

Write on firebase the first time


Update the score:

Read the leaderboard:

that’s all

2 Likes

Thanks Man. Can you also share the rule for firebase

There is a yt tutorial : GDevelop Online Leaderboard Tutorial - YouTube

Thanks a lot. Everything works as expected. I also added Firebase anonymous authentication and used the user UID as my document name instead of a random number. Therefore each document’s name is the corresponding player’s UID.

One last help please. If I want to load the current player’s detail and display his name and score. How to do it?


I think my variable syntax is wrong.

added Firebase anonymous authentication and used the user UID as my document name instead of a random number.

Wow, how you did it?

To load the current player’s detail I suppose you have to use the queries but now I can’t test it. If you want you can share your code and I will work on asap

First use authenticate anonymously action. Then change the value of player.guid to Firebase:GetUserUID()

1 Like

Hey! Can you give me a new version of the example?:pleading_face:

hy!!! can you help me to understund better?? in your answer i already know… it is programming logic… but in syntax??? i talk about action and event… i have used login exaple and score example… have a way to change uid??? uid in screen shootCattura

and another question is… when player register i want create a document in cloud store… is possible??? cause if every player make a random document is impossible recall
Cattura

soo glad for any help