 Competition is a core aspect of arcade and casual games. Having a leaderboard with the best players and their scores really sparks players' engagement. That said, how to implement a leaderboard? Loot Locker is a service that provides solutions for indie games, especially for database management. So it's perfect for that kind of stuff. It has all sorts of where-to-use tools that help us implement all those fancy features that online multiplayer games require. Account authentication, leaderboards, assets and inventory management, triggers if you want to make in-game events and reward players, push-a-thin billing, which is cool if you want to make money out of your game, right? And even more, you name it. So in this series of videos, we are going to see how I implemented these features on Moons Teaser, because it really needed them. The first thing we need to do is to create an account on Loot Locker. For that, we can go to my.lootlocker.io and click on Create Free Account. After logging in, we need to create a new game. For that, just click on the New Game Green button. Click on Setup New Game to create a game from scratch and enter some settings for your games, such as its genre, name and other stuff. Then select the platforms you want to publish the game. I chose Android for Moons Teaser. After you set your game up, Loot Locker would display a dashboard where you can manage it. There are some struggles about what to do next, including how to set up a leaderboard, but let's focus on the first step, which is to authenticate players' accounts. To sign in the player to a new PlayStation, Loot Locker offers a cool API that allows us to make guest logins. In a guest login, as long as you pass the same valid player ID, Loot Locker will either create or retrieve the player data on their database. So for instance, here on Moons Teaser, if the person is playing on Windows, Linux or HTML5, the game uses the OS Unique ID to login. This way, unless the player changes the OS, we can retrieve their data. In this project, I've also set up the Google Play service add-on, which allows me to use the player's Google Play account to sign into the game. Let me know if you want a video about how to install and use this plugin, because it's essential for people wanting to make games for Android. Nonetheless, back to the video. If the player is on an Android device, the game uses the add-ons signing method to retrieve a dictionary that has a key to the player's ID. Then I can use this ID on the Loot Locker singleton so it can authenticate a new player session. Let's see how this singleton works. In order to perform a login, we are going to mess with dark sorcery. HP requests. I've been avoiding this kind of knowledge my whole life, but it was inevitable. The time has come. To use such powerful magic in Godot Engine, we are going to use a special node. One capable of ending such power and become a vessel so we can control this chaotic force, the HP request node. The main feature of this node is that it encapsulates all the procedures necessary to perform HP connections in a single method called request, which can pass the URL, some header arguments, the connection method you usually post or get, and the request body, which is what we should pay most attention to. When the request completes, the HP request emits a signal with some important data. The most important one is the body of the response given by the other side of the connection. In this case, the Loot Locker servers. Okay, quite confusing, right? So let's see in practice what this all means. To make a login on Loot Locker, we do a request to the following URL. The header should contain this text. Then we should use the httpclient.method post for the connection method. And finally, for the request data, we should pass a JSON dictionary with the following structure. The game key, which we can get on the Loot Locker dashboard so we can go to the game and then settings, game settings, API, and there is the game API key so you can copy and paste this text there. Then we have the game version which you can pass any alphanumerical value so we can just maintain and control the version of the game that you are using. Then we have the player identifier key which is the most important one. This is what we should ensure that we are passing the same data. This is where we are going to use the OS unique ID or the player's ID that we can get from the Google Play Store API. Then for testing purposes, we can pass another key, which is the development modes and pass the value true so we are just testing out this whole thing. With this, we should wait for a response from the Loot Locker servers. One troublesome aspect of dealing with network and especially with HTTP requests is the fact that while we don't get a response, the game still runs. This is what we call a synchrony when code processes can get out of synchrony. So we must use the yield keyword here to wait for the response. Using this keyword, we can stop the code from running until this object emits its signal. We can access the signal arguments as an array that the yield keyword returns. The fourth index of this array corresponds to the body of the response that we want to get from the Loot Locker service. So let's start it here on this response variable. We must pass this text as the JSON dictionary so we can access the important data. This dictionary has exactly what we need, the section token key. This is what tells us that the Loot Locker authenticated the player and a new section has begun. We need to start this section token so we can access it on further request moving on. Okay, this object will wait for the Loot Locker service response, but everything else still works. This means that players can, well, mess things up. So weird errors and bugs can occur. How do we prevent that? Well, I created an object to overlay everything and prevent interactions from the player. It also has some predefined text to communicate the current game state. So I called it network state label. The most important part is that it should consume inputs to prevent them from reaching other objects in the same tree. For that, I use the input callback to consume inputs and I've also set the mouse filter property to stop. This object has some animations to make the labels text more interesting. For instance, this is what it should display while authenticating. I turned this object into a single tone so other objects can easily access it. For instance, in the Loot Locker object, I call this method to play the authentication animation. And this other one, after we receive the service response to play the authentication successful animation. If everything goes well, we should get a successful login. We can even see this player data on our Loot Locker dashboard. Well, this is it for this video. Coming next, we are going to use this player data to create a leaderboard with the 10 highest scores. See you there. Thank you so much for watching. Keep developing and until next time.