Solved Leaderboard

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

ZhengYueMoon

Member
Mar 9, 2022
17
0
1
24
So, I want to know is there ANY possible way to make Leaderboard in skript? it will the show the top players on certain variables, like, the top 10 of it.So I want to know is there any possible way to make a leaderboard using skript. Thank you.
 
So, I want to know is there ANY possible way to make Leaderboard in skript? it will the show the top players on certain variables, like, the top 10 of it.So I want to know is there any possible way to make a leaderboard using skript. Thank you.
Code:
command /baltop:
    trigger:
        loop {money::*}:
            if loop-value is not "<none>":
                add 1 to {_size}
                if {_low.to.high.list::%loop-value%} is not set:
                    set {_low.to.high.list::%loop-value%} to loop-index
                else:
                    set {_n} to -1
                    loop {_size} times:
                        set {_n} to {_n}+1
                        {_low.to.high.list::%loop-value-1%.%{_n}%} is not set
                        set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
                        stop loop
        send "&8----------------- &eBalTop &8-----------------"
        set {_n} to size of {_low.to.high.list::*}
        loop {_low.to.high.list::*}:
            set {_high.to.low.list::%{_n}%} to loop-value
            set {_n} to {_n}-1
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            stop loop if {_topnumber} = 11
            set {_player} to "%loop-value%" parsed as offline player
            send "&9##%{_topnumber}% &8&l» &f%{_player}% &8- &e%{money::%loop-value%}%"
        send "&8----------------- &eBalTop &8-----------------"
 
There is actually much better way that does not cause any lag, even if the list variable has lot of data.


Code:
command /top:
    trigger:
        set {_top::*} to sorted indices of {money::*} in descending order
        loop 10 times:
            add {_top::%loop-value%} to {_top_10::*}
        loop {_top_10::*}:
            add 1 to {_n}
            send "&a&l%{_n}% &7- &2%{_top_10::%{_n}%} parsed as offlineplayer% &7- &6%{money::%{_top_10::%{_n}%}%}% " to player

You can also put that in function..
 
  • Like
Reactions: Jake
yeah, i know the "sorted indeces of {} in descending order" but i spent a long time figuring it out cuz i thought it was "sorted {} in descending order"
 
Status
Not open for further replies.