1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Leaderboard

Discussion in 'Skript' started by ZhengYueMoon, May 28, 2022.

Thread Status:
Not open for further replies.
  1. ZhengYueMoon

    ZhengYueMoon Member

    Joined:
    Mar 9, 2022
    Messages:
    15
    Likes Received:
    0
    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.
     
  2. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    Code (Text):
    1. command /baltop:
    2.     trigger:
    3.         loop {money::*}:
    4.             if loop-value is not "<none>":
    5.                 add 1 to {_size}
    6.                 if {_low.to.high.list::%loop-value%} is not set:
    7.                     set {_low.to.high.list::%loop-value%} to loop-index
    8.                 else:
    9.                     set {_n} to -1
    10.                     loop {_size} times:
    11.                         set {_n} to {_n}+1
    12.                         {_low.to.high.list::%loop-value-1%.%{_n}%} is not set
    13.                         set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
    14.                         stop loop
    15.         send "&8----------------- &eBalTop &8-----------------"
    16.         set {_n} to size of {_low.to.high.list::*}
    17.         loop {_low.to.high.list::*}:
    18.             set {_high.to.low.list::%{_n}%} to loop-value
    19.             set {_n} to {_n}-1
    20.         loop {_high.to.low.list::*}:
    21.             add 1 to {_topnumber}
    22.             stop loop if {_topnumber} = 11
    23.             set {_player} to "%loop-value%" parsed as offline player
    24.             send "&9##%{_topnumber}% &8&l» &f%{_player}% &8- &e%{money::%loop-value%}%"
    25.         send "&8----------------- &eBalTop &8-----------------"
     
  3. Zyxed

    Supporter

    Joined:
    May 17, 2021
    Messages:
    23
    Likes Received:
    1
    There is actually much better way that does not cause any lag, even if the list variable has lot of data.


    Code (Text):
    1. command /top:
    2.     trigger:
    3.         set {_top::*} to sorted indices of {money::*} in descending order
    4.         loop 10 times:
    5.             add {_top::%loop-value%} to {_top_10::*}
    6.         loop {_top_10::*}:
    7.             add 1 to {_n}
    8.             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 Like x 1
  4. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    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"
     
Thread Status:
Not open for further replies.

Share This Page

Loading...