 Hello guys, it is crypto grounds here. Welcome back to another video. Um, yeah, 500 subscribers. Woohoo. I have a I have a 500 subscriber special coming out soon. I have finished recording it, but I decided I wanted to make this video first Since it's been highly requested throughout my entire channel and I Finally got to making my own Server-based leaderboard and unity and that's what we're gonna be doing today. I have my Document right here. It's got 50 freaking steps. So it's gonna be a little It's gonna be a little annoying of a journey, but anyways, we will do that Okay, so what you're gonna want to do is sign up for an AWS Amazon accounts Amazon web services. So make sure you make an account. I will kindly go through the I kind of go through the process of making it count So you're gonna want your put in your email address your password and your count name Which is used to sign in I'm not gonna. I'm not gonna go past here, but So it'll ask you for a professional or a personal user I use professional I don't really think it matters But I would recommend it's professional and then you're also gonna get this picture right here You're gonna get this makes you choose the basic plan and you should be good to go Yes, so you will once you make your count you will go to the dashboard. Let me close this real quick So let me sign in real quick So you will be brought to this screen right here The AWS management console. So what you're gonna do is launch a virtual machine with EC2 You will get this dashboard right here What you're gonna do is select the Amazon Linux to AMI, which is the first one make sure you choose the x86 archetype whatever it's called and For testing purposes, I would choose t2 micro All these settings should be good Storage that should be good actually here. I Think this is good Yeah, this looks good. So The storage should be good. This honestly all should be good to go and yeah, so Once you launch it, hopefully I'll be able to remove mine Let's see. Okay, perfect. So you're gonna get the screen So you want to create a new key pair after all this is set up and once you click launch Oh, and yeah, create a new key pair Choose a name and download it and save it to a folder on your desktop Now I don't want to go through this process again because I already have it see I have mine right here It's called CG access that PEM. So make sure you download it somewhere You'll remember it never lose it. You're gonna need it maybe in the future Do you want to make another instance or something like that? So anyways, I have mine set up already? So I'm not gonna I'm not gonna go through the process again So What's next? Oh, yeah, so you want to download putty so search a putty online you will get this right here and And Download the 64 bit. It's the installer msi. You will run through the installation process And that should be pretty self-explanatory Then you want to launch putty gen What you want to do is load Your dot PEM file so you won't see it here at first But make sure you choose all files and open up this dot PEM And then once you load it, you know what I'll load it here since I'm probably not going to use it Okay, so once you open it in you're gonna have a key passphrase. So make sure you just type in two passwords and That should be good to go you want to save as a private key saving the same spot as what you have your dot PEM Folder and you should be good to go Next you want to open up petty. I meant putty I think that's how you pronounce it. So what you want to do here is after you make your server you're gonna want to go to your instances and Click on your main one and copy this public DNS right here and That's gonna go right here Before that make sure you type EC to dash user at and then your public DNS Make sure you keep the port for 20. It's make sure you keep the port to 22. I will be important for later and Go to this SSH right here. Make sure you expand it by pressing the plus sign click on off Keep these settings except for allow agent forwarding and Then you're gonna want to open. I've already done all this before so Yeah, we should be good to go so you open it you'll get this kind of console right here and If you get a pop-up that says it's just like a some random alert may she click ignore or just click Yes to ignore it and what you want to type here is run. That's you want to do Want to type in pseudo Yum update Why for yes? Okay, we're good to go for that and then what you want to type is pseudo yum install Tmux so what this does is that it basically allows you so I already have installed it Which why I didn't show anything from you basically allows you to close everything You don't have to touch it ever again. The server will be running endlessly on the back end at AWS Very helpful. You don't have to keep this stupid console open at all times So yeah, make sure you do that Next up Start a new app. So you want to take new you want to do tmux New dash s and choose a name. I'm just gonna put Name I'm just gonna put serve serve for server Okay, so this will be our window or our console that we will be interacting with After that, let's see. Where are we? I am looking at my instructions because there's no way in hell I can remember how to do this from scratch Um, so when you do close this in the future in order to resume back to this you can do tmux A dash t and then serve and then or serve and you'll be back to where you were So that's kind of convenient Let's see. Oh, yeah. All right. Next. So you want to go to cyber dot cyber duck Dot io Get it from my download for mac os windows do not do this one because you have to pay for it And you'll click the cyber duck for windows right here, which I already have it Hopefully I won't install. Yeah, so you just run through the installer And you should be safe there Um, what's the next so, um, open cyber duck. Yeah, allow. Okay Okay So what you want to do is click open connection And I want you to choose sf tp In the server you're going to put Um, why did you put oh, yeah the server it's your dns. So just put that in there And for your username It's ec2 dash user And keep the port is 22 You don't need a password And for your key go click choose Go to your whatever you saved it and choose that private key. So this is mine right here new key with password Okay. Oh one very important step. I totally forgot to do so close all of this real quick You can just do control c actually, you know, just close this Totally, I've totally forgot to do this one step. You see this app right here pageant right here Double click it And you'll see this list right here. So what I want you to do is add a key And I want you to add your new key with password make she add it to this list And then you're safe to close Um, so we're gonna need to run putty again because I'm an idiot and I totally forgot one step Just do what we did Before easy to user. I have my default settings right here. So I can just load it. You could save it too Just in case you do need to load it again Go back to off agent forwarding Open there we go. We should be safe to go And we can also do tmux a dash t serve There we go. See we're back to where we were before and had our previous commands I think that's just really cool and honest and in my opinion um Okay, so Opening a connection. What was I doing? I think I stopped in the middle. Oh, it's right here. So, yeah, make sure you choose your dot ppk that you have created Um, and then you click Connect. Yep. So I'm not going to connect because I already have one connected So on here You need to install node. So this is quite a Combination of things to do. So I want you to type When you paste it in here, you will need to right click it for it to, you know, continue to paste Um, I'm dumb and I kind of Okay, yeah, so just Right click the pace. Oh, so copy or no paste it Control v. Why isn't it working? So Copy or just type down what? Yeah, just ignore what I'm saying. Just type down this command Enter So I've already installed it. So I'm good to go and then what you're going to type here Is to activate node type that Okay, should be good to go and then search and then type nvm install node I'm not going to go through the installation process because I've already done it But that's what you type and now we need to install something called the yarn in order to access our server So we're going to paste that in here. It's the curl With the dash o make sure you copy everything Exactly right because it will mess up And then you'll press enter, but I don't need to do that. Sorry. I haven't installed And then what you need to do You need to close this after you installed it So do control b and then let go and then type x and then y And then you need to do tmux a dash t serve Oh, um, it's it's I forgot we close the session. So we have to make a new one Don't worry. It's not a big deal if you have to make a new one or not So you do new dash s serve Here we go. We're back to where we were The control b and accept completely shuts down the Our app so we have to create a new one every time And okay, so now we're going to go back to our instances where I scroll down to security groups Click on our launch wizard one Right here go to inbound edit And I want you to copy these two right here this one you should have already But I want you to make these two right here. So I'll take a look for a second while I get ready Okay, and then you want to save And then we are going to do yarn install I already have it installed. So I'm just gonna yeah see it's already up to date And then what we're going to do we're going to create our strappy project Which is what we're going to be using our server for Um, so we're going to go here. I want you to type yarn create strappy App my project I don't want to make a new project because it's going to take a really long time to make it in here because you have such a Slow server it took me at least an hour I don't I mean it took me an hour to convert mine on my desktop to the server So I don't know if installation will be the same But I'm not going to go through that process because I don't want to wait an hour While I'm recording, but you type this command You should be good to go um And then exit out of the project. So you're going to do the control b Control b x control b x y and then you're going to do teamux new as serve again and then You're going to You're going to go to cd Whatever your project name is that's mine And then I'm going to type yarn start So the reason why I wasn't able to start the Start the server properly is because I already have one running So I don't so we're all good. Let me actually check just to make sure I actually have my server so running And other things you don't want to share this url with anyone I've I've been blocking it out because I don't want anybody to see it Oh, right. You need to do I type in the port as well Which is 13 37, which that's strappy's port and there you go So here is where our stuff is being stored just for an example But yeah, so that's where mine is once you start it you should be able to do slap You won't go automatically, but I want you to put your dns here Put the port and then type admin And then you should get a login here mine's mine's different because I already have an account, but I want you to create your account So let's I'm going to log in for me because I already have an account Remember me I mean already Yeah, um, okay So your screen is going a little bit different because I only have one content type But first thing you're going to go to users And I want you to add yourself so add your username and your email that you used to log in You should be good to go And then go to roles and permissions go to the public one right here I also sorry if I'm going really fast. I'm trying to make this a really short tutorial So it's not an hour long. So you got to wait for me to explain something I want you to be able to pause the video continue and I'll be at the next part And there's no step. I'm skipping here. I'm make sure I get everything Okay, so for the events I want so it'll look like this So make sure you select all And then you're going to have to add a group So make sure you add a user if that doesn't show up just add your username right here So you're able to create events and stuff like that Um cancel because I've already done that so go to content type builder I'm going to make a new one. I already have my events one right here Well, let's create a new type and call it tutorial Continue So what we're going to add to this tutorial is right here So we're going to add a text. This is going to be our username Make sure you keep it capitalized and make sure in your script it matches this too Just just so you know ahead of time Uh add another field we're going to add a number And I choose decimal since I use doubles You could use strings if you wanted to if you want to do if you want to convert your big number If you do big double you convert that to string and submit it here It works exact same But I'm going to do a number because that's how I do it Um I'm going to do it money Finish so we have our two fields right here And we should be able to refresh and we should see that at the side right here I don't know where to go. Oh shoot. I actually did something. I forgot to save it Let me create it again User name Add another field number coins Finish ah shoot decimal finish save Okay, it didn't save for some reason. I don't know why I think I'm allowed to have one content type only But this is what yours should look like it should be empty. So just ignore this right here But this should be empty right now Um, you can create a test one if you wanted to you just go to add new events type in your username Hi, and I put my number in here. I'm gonna put 10 Save it up that will be showing up on my leaderboard the next time I play my game So yeah, it's cool it updates automatically and yeah, so So the thing I'm going to show you what to what to do next is go to your link So when you want to see your data as a text For me since I made tutorial I would search up tutorial, but for some for some reason it didn't create I'm just gonna use mine as events, but yours would be your name. Make sure it's all lowercase And see here. There's my leaderboard. There's the high that I made And oh another cool thing so you see this id right here 56 you can go to slash offense 56 oops And you'll see this individual one right here. This will be used really useful for replacing uh Very replacing numbers like updating the leaderboard instead of having to add one every time which I will explain later on But yeah, so don't forget that this is lowercase right here. See mine's events. I would use one word also um I think that's all I need to show you there So let's now we can hop on unity Keep this open. You're gonna need it So let's make a new Let's use my idle game tutorial series even though it's not part of it Ah, shoot. No, I don't I don't want to use it. This is connected to get hub Rats, I didn't I didn't want to do that. I wanted to start a new project I'm gonna make a new one called leaderboard making two projects now oops Yeah, while we're waiting my 500 subs special I am almost done with that It's gonna be it's gonna be a special cookie. I'm gonna tell you guys that it's gonna be a good video It should be fun. It's gonna be long, but I feel like that It's it's a different video. It's something I haven't done before but I feel like you guys should like it Uh, you saw my script. Oh, no Okay, so all right, let's create a canvas real quick. All right. I hate this is the part I hate ui canvas ui text we're just gonna make We're just literally just gonna like make a very basic project because I yeah, we don't we just need us We need a little giant text So this is how we're gonna format it. It should look like this one name number 100 Now the thing I'm not going to show you here is how to set your username because I've done that in one of my clicker hero Tutorial, so I'm gonna have a a name set already. So every time we load We're gonna, you know show it Show what it looks like. So here we need to make a script call We can just name it anything. I'm just gonna call it leader leader leader b because I don't I don't really don't care um Open up this script So I'm kind of I'm gonna be kind of all over the place. So just be just be ready for this Okay, so I'm gonna copy and paste a class that I've made on the side called leaderboard entry We can get rid of id because that's not really relevant. Actually, we will need id never mind. Um, so Yeah, so this will be our coins right here um leaderboard entry That's be good Now we need to copy and paste This should be capitalized This should be capitalized. We don't need id We are going to Have two methods. I like starting from scratch public void start. We're gonna have a username be username be crypto grounds to Doe grounds 2.0 And our coins will be 154 146.7 just some random number um public void updates Okay, so now let's let me hop down to my server right here I'm at my leaderboard um Okay So we need to have So we're gonna we're gonna make a few things We need to have two more classes above this Oh, we also need a using system as well in order to serialize this stuff Okay, so Screw that we're removing this to our main class. So we could put classes inside Other classes if you didn't know that so here you go. We should get no errors here replace this with Coins and actually we don't need this leaderboard entry. I don't know why I still have that Yeah, we don't need that anymore. Okay, so just get rid of that Sorry about that. See I told you I'm gonna be a little bit out of place. So just don't skip anything And we need a string here And I want you to put your dns right here So I'm gonna paste mine I'm gonna block it out make sure you have the slash events too And I'm gonna I'm gonna copy and paste method by method explaining like those So here's one right here This is post to leaderboard Ah, we need another one using unity engine Dot UI for the text that we're going to use in the future and unity engine Dot networking I'll give us ability to use unity web web web quest um replace some of this data so leaderboard data Ah shoot coins. This should be coins Okay replace coins with That It should just be username username username Okay No, let's see what's wrong here. I'm gonna copy and paste all these up here. I think we need system dot link as well So let's see. What do we not need here? Yes, we need system link. I have a feeling That gives us ability to use dot count as well. So this should be the four things you need Uh accidentally do accidentally deleted UI So Honestly, I think we can delete this but I'm just gonna keep it because I I don't want to retest that honestly So basically what it does Is it grabs it creates a new leaderboard data It sets this so it's an empty it sets coins Right here It sets coins to zero All right. No, no, no. Yeah, so it starts with everything starts with zero or blank um It grabs the coins which is going to be for 146.7 which will be set here and We don't set username yet because We don't need to do that yet Yes, okay, perfect. Um, so then we're gonna um use json utility To json to convert this um to convert this whole thing into json into a json string And the reason why we don't want our username here is because we want to it's because we want to do something here Which I'll explain in a second and then we're going to convert this json string to a bunch of bytes Which is what unity webcrest will be able to Use to send that those bytes to the to the server And it's really cool how it works, but so we're going to create a unity web request called request And basically this right here it checks if the leader board event leader board um if Trying to think okay Trying to think what I did here Basically, it's supposed to check if leader board already has Yeah, so it checks if username already exists in this array and If it does then we will go to this for state for statement right here which basically This event leader board Okay, I okay. I got myself confused for a second. I understand what's going on now, but this right here This this will be grabbed later on So you'll see where this comes from but basically There's a method that will grab the entire leader board and store it into an array okay So it's going to check my entire leader board to see if this our username crypto grounds 2.0 exists If it does already then we need to update that variable instead of creating a whole new one Or else we'll see two crypto grounds 2.0 So we so that means it'll go to this for loop where It'll start from beginning which is like the first entry to the last one It'll check if any one of them Is equal to use it has the same username if it's the duplicate Then basically we will we'll just completely delete it from the leader board So we do that by doing request equals unity web request dot delete. We put our dns right here We add a slash and then the leader board id And that's cool because that's where we see this right here. See this slash 56. That is exactly what we're doing right here So another thing I also want to share before I continue these id's they never reset they don't go back to one So every time I make a new id 57. Oh, it would be 57 if I delete 57 I create another one It'll just jump from 56 to 58 so that never decrements it always increments Which is why I made this id thing Because I don't want to I don't want to go from one to something like I really wish I could I don't make the things a little bit easier, but that's why I put this id here And that's why I have The id right here anyways So it will delete it Now we'll go to the actual part So if this doesn't happen, this is basically ignored It's gonna complete it's gonna make a new so basically deletes that duplicate And then it doesn't exist anymore And then we set username to our username We we set json we convert it to json again. We convert the bytes again, and then we do Um a post instead So we actually post it again So we delete it, but then we post it with the updated coins Which is which is what which is our goal. It's took me so long to figure out It was actually kind of fun to make it But yeah, so we had to do that And then Um Yeah chunk transfer no idea what that does So we want to set the content type to application.json or application slash json But there is a website I've used where you can set like push data to it to your dns And basically there's different ways to do this hdm you can do html and stuff like that So I did a application.json since that's what we're using up here And then we ended off with request send or request dot send web requests Which basically updates it and we're good to go That was a butt load. Oh my gosh So I'm gonna put this in the updates really what I do for mine Is that I do post to lead board whenever someone completes a challenge or an event for crypto clickers So do it my advice is do it as Less often as possible because you're paying you're paying money for that t2a.micro Server that I bought that you bought or you didn't really buy yet really I haven't spent any money yet I'm sure that will come after a year but you will I mean You don't want you want to use as much data as possible Because if you're gonna have 100 000 users is it in posting every frame It's it's just not gonna look good your server will crash consistently You'll be spending a bucket load of money. So use this as Use it as least as black Use it as less as possible. Okay So we should be safe here You know, I just realized I might actually have to make a new one. You know It's okay. It's okay um I'm gonna come back to my old script. I'm gonna Re-pace time tokens this week Even though it's supposed to be coins, but since I don't want to make a new one. I'm using time tokens this week Okay, so it's the same thing just replace yours with coins Uh, I'm gonna make a button Actually, we can just make a button that post is it. So yeah, we're good there. So next we need to get our scores And this is this method right here unity web requests. Oh, I numerator great So what are you using here now? I think it's system.collections. Yes, it is Okay, so now we should be able to use i enumerators, which is required in order to forget for this to work um, so basically we're just we're just getting um, we're treating our data from the dns And we yield return. I don't I'm not really sure how to explain how this works, but there's an error It's gonna show an error and it's not gonna update Um, but basically we're converting this download handler right here That's basically our entire like what I showed you earlier. It's the entire website and then we convert it to json Actually, no, it's already in json So we're going to convert it from json into this wrapper method right here So we're basically converting it back into data right here And then this line right here is very important basically It takes this entire invent invent event data and it And it orders it from the highest number to the lowest. That's how we get that leaderboard ranking Okay, so that's how we get Let's see. What am I missing? Yeah, we need a leaderboard text So just put that up there So next Yeah, sorry if I'm not making any sense. This is I'm not very I'm not very good with this So paste is here So this right here Ah shoot, I did not copy copy at all Okay, so basically this star core chain get scores will run this get scores right here So another thing you should really run this once a minute or so Or make it once every five minutes But have a button that autumn that that people can click to update it with a max with a minimum time of one minute Just so you can save space or speed and stuff like that Um, so yeah, I'm just going to put an update for now just for testing Um, see I said the leaderboard text to blank Um create a counter setting at one and for each Why is this like this? I don't I don't know why it's doing that. That's supposed to Oh, right. There we go. Okay, so For each data inside this, um event leaderboard right here We're gonna grab We're gonna start with the first this is the first place So remember we're going from highest to lowest so it's already sorted right now So we're going to go to even data counter. We're going to put a dot We're going to put the username and we're going to put our coins right here And then we start a new line and we add to the counter and it continues And I believe we are done Um So yeah, um, okay We can test so this is where things can go wrong Okay, so this is our leaderboard text and our event leaderboard. We're going to save And we're going to cross our fingers and play So here's our leaderboard right now What I want to do real quick, I'm not going to save it because this is just a quick button thing I'm going to make so we're going to create a button right here Make sure you're not in play like I am I'm going to add my canvas to this go to leader B And post the leaderboard ready There there we are right there. So now if we post again see how it updates like that Instead of adding us twice. It just replaces it So I'm actually going to add this button like legit so we can see So canvas leader B post the leaderboard So just put that right here see how it saves and it always updates and Nothing can change it either Okay, so we're going to post again nothing happens Now let's make this time tokens 500 See how it updates now if you put one now we're in last place All right, so once again Make sure you Create an aws account make sure you create an instance how like I have like I did download putty download cyberduck You're using strappy You make sure you have your dns with you at all time Because you're gonna be using a lot make sure you don't show it with anyone else Um, yeah, I hope you guys enjoyed that tutorial is a lot shorter than I thought anyways have fun Which you got I'm wishing you guys luck if you guys have any questions I probably can't help you because I had someone else help So anyways a shout out to number engineer who made incremental unlimited Incremental unlimited Let's go here. I don't want to go to the reddit Where is the play store right here who made this the game so make sure you install the game on android only And yeah, thanks for watching download or donate donate to me on kofi download my um Download my Download my project on patreon if you're interested this project will not be included just because Um, you gotta watch the full video in order to understand what you're doing and just that's just you just gotta watch the full video Yeah, anyways, thanks for watching. Have a great day. Subscribe like the video. It's from vacation news. Peace You