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.

LukynkaCZE

Member
May 12, 2019
26
2
3
29
lukynka.ga
Hi, I want to make a leaderboard.

The one who has the most {points ::% player%} is on top and the others are sorted in descending order below


I've tried something but nothing worked.


Please help :emoji_slight_smile:
 
Hi, I want to make a leaderboard.

The one who has the most {points ::% player%} is on top and the others are sorted in descending order below


I've tried something but nothing worked.


Please help :emoji_slight_smile:
Try:
code_language.skript:
on command "/ptop":
    cancel event
    
    loop {points::*}:
            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 0
                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
        wait 1 tick
        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
        wait 1 tick
        set {_i} to 0
           
        message "&a&lPOINTS TOP" to player
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            add 1 to {_i}
            message "&8%{_topnumber}%.- &a%{_player}% &8» &a%{points::%loop-value%}% Points"
            if {_topnumber} > 9: #or the number of the number of positions you want to have in your leaderboard.
                stop loop
 
Try:
code_language.skript:
on command "/ptop":
    cancel event
   
    loop {points::*}:
            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 0
                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
        wait 1 tick
        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
        wait 1 tick
        set {_i} to 0
          
        message "&a&lPOINTS TOP" to player
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            add 1 to {_i}
            message "&8%{_topnumber}%.- &a%{_player}% &8» &a%{points::%loop-value%}% Points"
            if {_topnumber} > 9: #or the number of the number of positions you want to have in your leaderboard.
                stop loop
Register // Don't use on command to run a trigger but Register it as command Because it has less packet sending
 
Status
Not open for further replies.