Accessing Leaderboards and PlayerAuthentication via gdjs.evtTools

Hi, I’m new to GDevelop, but have been a long-time game dev (mostly Unity). I’ve been working heavily in JavaScript the last month or two, and I just jumped over to GDevelop. I understand this is mostly a no-code tool, but I’ve been trying to recreate samples (Tappy Plane specifically) in pure JavaScript. I have the game completely copied over to JavaScript except for the parts where I have to call leaderboards and playerAuthentication. I see the documentation for both:

However, when I inspect gdjs.playerAuthentication or gdjs.evtTools.leaderboard, these variables are null. What is the proper way in javascript to access these tools. Thank you very much for any help you can provide! Cheers! - ET :slight_smile:

Found a solution! Reference them at least once in events!

It seems the reasons these weren’t being loaded is because none of my events were using authentication or leaderboards. I added a “dummy” event to hide player authentication and leaderboards at the beginning, and now I can use both in JavaScript.

I do have a follow up question… I cannot save anything to the leaderboard… I am calling gdjs.evtTools.leaderboards.saveConnectedPlayerScore(runtimeScene, leaderboardId, score.getValue()); and I get the following error:

ReferenceError: jsSHA is not defined
    at U (leaderboardstools.js:1:223)
    at x (leaderboardstools.js:1:4996)
    at leaderboardstools.js:1:5578
    at i.savePlayerScore (leaderboardstools.js:1:5664)

Do you know what I can include in the project to also include jsSHA?

And solved again! This conversation with myself is going really well! I have to make sure I am SENDING a score to the leaderboard for it to include the jsSHA. OK, I think I’m good now! :slight_smile:

2 Likes