 Now that we have an authenticated player logged, we can do the fun stuff. In this video, we are going to make a leaderboard with the 10 highest scores of the game. Let's do it. The first thing we need to do is to go to our loot locker dashboard and go to the game that we want to add a leaderboard. So in this case, there's a new game here. And then we go to systems, leaderboards, and we can create a new one. Here we can insert a name to the leaderboard. I think that I will go with tests. The second one is optional, but if you want to, you can name it whatever you like. So you can refer it on the API call instead of the idea of the leaderboard. This one is important because the first one player, the type of leaderboard, a player leaderboard, will automatically use the player's name when retrieving scores. But this player name is internal on loot locker. So it's how loot locker name the players. So it can get it from the PlayStation network. I think that even the player, the Google Play service as well. So in our case, because I'm going to use this API for HTML games instead, I will go with a generic one. And we are going to pass the player name as a metadata. So we are going to enable this enable metadata here because when we make the API call, we are going to pass the player name as a metadata. We are going to retrieve it as a metadata as well. Then we have to enable the game API rights because this is how we allow the loot locker servers to accept API calls to change the data of the leaderboard. With that, we can save that. And we have a leaderboard on the loot locker servers. This is important. This is the idea of this leaderboard. So we are going to copy that because we are going to use that when we make API calls. So let's see how the API looks like. Okay, this is the API call that we should make when we want to submit a new score to the leaderboard. We should make a request, a post request to this URL. But instead of using this number right here, the number one, we are going to use the leaderboard ID or the board key, as you can see here in the URL structure. We go to game, leaderboards, then we send the leaderboard ID or its key, slash submit. Then on the request data, we are going to send a JSON dictionary that has the score and some metadata. This is not mandatory. This is optional. But we took out the metadata so we enable the metadata so we can send the player's name as well. So we can send the player's name together with the score. Then on the header, we can see that we need to send this content type, application JSON. But on Godot Engine, this is not enough. We should also send the session token together in the header. This is why having a successful player logged in and not dedicated is important for us. So let's see how this goes. So on Moon Chaser, this is how it goes. When players make a local high score, so they have a variable that saves high scores on the machine, so locally, the game will transition to this screen. So this screen has this line edit, which is what players use to submit the name. So we are going to use this text here, so let's say Sakaki. We are going to use this text here as the player's name. So we are going to send this text together with the player's score as a metadata. When we make the API request. And then you can see that we have here a high score HTTP request node, which is what this high score screen uses to make the actual HTTP request. So this is what it uses to make the API call. Let's see how this works. So the first thing that it does is that it fades out this rect here, the fade rect. Then the important part goes here. So we have this URL. You can see that it is what we saw previously. But you can see that I'm using here the name of the game. But this is actually a key that I use for my leaderboard. So the custom key, right? So instead of the leaderboard ID, I'm using a leaderboard key. But instead, you can use your leaderboard ID. Let's see this. So copy and paste it here. Then the header. And you can see that we have this content type application slash JSON. But we also have this. So we have a comma because this is an array. And we also have this part right here. X session token. And then a placeholder string. Then we replace this placeholder with the loot locker token. So the value that we gather on the previous video. So if you are curious to know how do we get this value here, you can watch the previous video because when we have an authentication, we set this value, the token value to be the token that we get back from the loot locker service, right? Then we have the method, which is method post. And then the request data, which is a dictionary with the score. So we have here the singleton with the high score. Then the main bear idea, which is the loot locker singleton player ID value. And then the metadata, which is the line edit text. So whatever the player submitted on this line edit node here. So in this case, Sakaki. Then we make the HTTP requests using these values. Don't forget to convert the request data to a JSON file. And then we yield for the HTTP request, which is this high score HTTP request node to finish the request, complete the request. And then we transition to the next scene, which is going back to... Oh, which is the other part of this video, which is the leaderboard screen. So let's see how this works. And this is the leaderboard screen. So when the high score screen finishes up, so when it finished sending the high score to the server and the server actually get the high score, it switched to this scene. Players can actually get here from the main menu as well as we saw in the beginning of this video. So this scene works like this. We have the leaderboard HTTP request, which is a HTTP request node. So let's see how this works. It has a method, which is the get board method, which firstly tells the network state label to show the loading board, the loading board animations. Then we have the URL, which is similar to the previous URL. But right at the end, so we have the game slash leaderboards, the leaderboard key or the leaderboard ID. So let's see if this is on the clipboard. And then we have this part of the URL, which is important because this is actually how many entries we want to get from the servers. In this case, we are using just 10 entries. So we are just getting the first 10 entries from this call. Then we have the header. And you can see that we have the content type, application slash JSON. And we are using the token as well. So X session token. And then we are using the loot locker token to replace the placeholder here. And for the first time in this series, I guess, we are using the method get for the HTTP request method. So we make the request using the URL, the header. We don't want any SSL protocol. Then we use the method here. Then we use for the response and we access the fourth index of this response, which if you saw the previous video, you know that is the request body. So we convert this body to a string. And then we convert this string to a dictionary. This is the call, the API call that we are making. So you can see that this is the request that we are making. We use the get method to this URL. And we are going to get this response. So this is a sample response. So we are getting something like that on our game on grow. So the items is a key that is an array that contains some data from the player. So from as many players as we are getting, we are going to do the following. We are going to make the items which we saw is an array, right? As the value of this board variable here. And each item of this array is a dictionary, right? So each item of the items key that we are getting from the response is a dictionary as well with some data that we want to get. So for instance, the score. And here if we have a player leaderboard, it actually returns the player as well. But instead we are going to use the metadata key. The leaderboard, let's see the design of the leaderboard here because it's quite important for the next part of this. So the leaderboard is a panel with a screw container that has a vertical box container as well. Each item of this vertical box which is the player list is a, let's see right here, a board entry instance. So let's open this scene right here. So in file system, board entry. So this board entry is basically a horizontal box container that has two labels which one represents the player's name and the second one represents the score of the player. So let's open the script. And when it is ready, it updates the labels. So we can set the player name variable value and the player score variable value. And when it's ready, it updates the labels to the labels text so we can match the value of these variables here. So back to the leaderboard screen. Let's open the top node script here. So we yield for the HP request node to finish doing what it does to get the board. So this node here, so it finished this function. And when it does, we run through each item of the board. We saw that the board is an array, right? And we create an instance of the board entry scene for each one of these entries. So for each one of these items that are in the HP request board variable. And then we set the entry, which is the instance of the board entry scene, the entry player name to match the metadata of the item that we are getting from the leaderboard. And then the score to match the score key of this dictionary. So just to remember everything up, each item of the board array is a dictionary. So we go through them and access the key, the metadata key, then the score key, and then we add each entry as a child of the player list. When everything finished up, we tell the network state label to show that the board is loaded. And when we do that, we get this. So let's play the game. We are going to get an authenticated player. When we go to the leaderboard, it loads the leaderboard and it fails. Oh yeah, because at this point, we don't have any player, right? So we don't have any entry on the leaderboard. So let's add some entries to the leaderboard. Let's do that. So let's make a quick run so we have some score to play with. So we have an authenticated player logged in. Let's play the game. And let's wait for something to happen. I think that this should do the trick. Okay, let's die. So let's say the player's name, the player's nickname, enter, and we have a board loading, board loaded. And there we have it. It's a kake with a score of 60. Now that we have a score entry on our leaderboard, we can actually manage it on the LootLocker dashboard. Let's see how this goes. So I'll switch to this camera. Let's go to the LootLocker systems, leaderboards, and we have the task leaderboard here. So let's view the scores. And there we have it, the score with 16 points, 60 points. So let's update this. Let's say that the players pay something to us. And let's change this to, let's say, a 2000. Save this. Then back to the game. Let's go here. Play the game. And we have a player logged in. Let's see the leaderboard here, loading board. And there we have it. Sakaki now has a score of 2000. So this is it for this video, guys. I really hope that you enjoyed it. Thank you so much for watching. On the next one, we are going to see how we can make assets and manage players inventory. So I hope to see you there. Thank you so much for watching. Keep developing and until the next time.