Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Leaderboard code
- amro3
-
Scratcher
2 posts
Leaderboard code
Hey guys, I need some help with making leaderboards on my game and I have no clue how to do the code. I want it so it shows a full list with the person with the highest score on top, and the person with the lowest score on the bottom. Also I only want a person's username to come up once, so if he played again, and got a lower score, he will go down on the list. Thank you! 

- deck26
-
Scratcher
1000+ posts
Leaderboard code
That's an unusual way of doing it - usually it will record a person's highest score and only replace if beaten - but no matter.
Here's a couple of leaderboard projects https://scratch.mit.edu/projects/91462262/ and https://scratch.mit.edu/projects/91501440/
Neither only stores the name once but it should be easy enough check the list before adding the name and only writing to the list if appropriate.
Here's a couple of leaderboard projects https://scratch.mit.edu/projects/91462262/ and https://scratch.mit.edu/projects/91501440/
Neither only stores the name once but it should be easy enough check the list before adding the name and only writing to the list if appropriate.
- jokebookservice1
-
Scratcher
1000+ posts
Leaderboard code
This Wiki article might help
And you could import the sprite from my project for my Cloudist module, but you you will have to make your own sorting algorithm.
To sort you could go through each value of the list and swap them if they are in the wrong order i.e an unsorted list with the values 4 3 2 1 would go
3 4 2 1
3 2 4 1
2 3 4 1
2 3 1 4
2 1 3 4
1 2 3 4
Hope this helps.
And you could import the sprite from my project for my Cloudist module, but you you will have to make your own sorting algorithm.
To sort you could go through each value of the list and swap them if they are in the wrong order i.e an unsorted list with the values 4 3 2 1 would go
3 4 2 1
3 2 4 1
2 3 4 1
2 3 1 4
2 1 3 4
1 2 3 4
Hope this helps.
- brettstahlman
-
Scratcher
21 posts
Leaderboard code
The following project contains a leaderboard implementation that does it all for you:
Leaderboard
Hope it helps. There are instructions for importing on the project page. Let me know if you have questions…
Leaderboard
Hope it helps. There are instructions for importing on the project page. Let me know if you have questions…
- Buster1600
-
Scratcher
1 post
Leaderboard code
@brettstahlman Your code includes my username multiple times, is there a way to fix this, as I am trying to do the same?
- dominic305
-
Scratcher
500+ posts
Leaderboard code
@brettstahlman Your code includes my username multiple times, is there a way to fix this, as I am trying to do the same?Pleas start a new topic and don't necropost
- Discussion Forums
- » Help with Scripts
-
» Leaderboard code