Jump to content

Skript leaderboards


1_x409

Recommended Posts

Hey hey! Maybe something a little like this?

command /leaderboard:
    permission: leaderboard.access
    trigger:
        set {_sortedEntries} to a new list
        
        loop all players:
            add player loop-player to {_sortedEntries} with value of {toproll::%uuid of loop-player%}
        
        sort {_sortedEntries} by value from highest to lowest
        
        send "&e===== Leaderboard =====" to player
        loop {_sortedEntries} as {_entry}:
            send "&6%{_entry}%: %{_entry}%%" to player

Let me know if this works!

If I helped you at all please consider boosting my account with the follow button!
Minehut ♥ [VIP] 12/19/2020 - Present

I am either extremely active or not lol.

 

Link to comment
Share on other sites

Sorry, i'm mistaken. To create a leaderboard with holograms for a variable called {toproll::%uuid of player%} in Skript, you can use the following code:
 

command /leaderboard:
    trigger:
        create hologram at location 0, 100, 0:
            format line 1 with "&6&lTop Rolls"
            set line 2 of hologram to "&7-----------------"
            loop all players:
                set {_player} to loop-player
                set {_roll} to {toproll::%{_player}%}
                if {_roll} is set:
                    add {_player} to {_sorted_players::*}
                    add {_roll} to {_sorted_rolls::*}
            sort {_sorted_rolls::*} in reverse order
            loop {_sorted_rolls} as {_roll}:
                set {_player} to {_sorted_players::%loop-value%}
                set {_formatted_roll} to format number {_roll} rounded to 2 decimal places
                set line 3 of hologram to "&e%{_formatted_roll}% - %{_player}%'s Roll"
                remove {_player} from {_sorted_players::*}
                remove {_roll} from {_sorted_rolls::*}
                delete {_formatted_roll}

This code creates a command called /leaderboard that will update the hologram to display the leaderboard. The hologram is created at coordinates (0, 100, 0) but you can modify these coordinates to suit your needs.

To use this code, you need to have the Skript plugin installed on your server. Make sure to copy the code into a Skript file, such as leaderboard.sk, and place it in the Skript plugin's script folder. After that, you can reload or restart your server, and the /leaderboard command should be available for use.

When you execute the /leaderboard command, the hologram will update with the top rolls, displaying the roll value rounded to 2 decimal places and the player's name.

Please note that this code assumes you have already stored the roll values in the {toproll::%uuid of player%} variable for each player. You will need to update that variable in your Skript code or plugin logic accordingly.

If I helped you at all please consider boosting my account with the follow button!
Minehut ♥ [VIP] 12/19/2020 - Present

I am either extremely active or not lol.

 

Link to comment
Share on other sites

My apologies, I think I might have redefined the variable and tried to use it when it wasn't the first definition. I added a player cache in this one, let me know how it goes!
 

command /leaderboard:
    trigger:
        create hologram at location 0, 100, 0:
            format line 1 with "&6&lTop Rolls"
            set line 2 of hologram to "&7-----------------"
            loop all players:
                set {_player} to loop-player
                set {_playerCache} to loop-player
                set {_roll} to {toproll::%{_player}%}
                if {_roll} is set:
                    add {_player} to {_sorted_players::*}
                    add {_roll} to {_sorted_rolls::*}
            sort {_sorted_rolls::*} in reverse order
            loop {_sorted_rolls} as {_roll}:
                set {_player} to {_sorted_players::%loop-value%}
                set {_formatted_roll} to format number {_roll} rounded to 2 decimal places
                set line 3 of hologram to "&e%{_formatted_roll}% - %{_player}%'s Roll"
                remove {_playerCache} from {_sorted_players::*}
                remove {_roll} from {_sorted_rolls::*}
                delete {_formatted_roll}
                clear {_playerCache}

 

Edited by JoshG

If I helped you at all please consider boosting my account with the follow button!
Minehut ♥ [VIP] 12/19/2020 - Present

I am either extremely active or not lol.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...