Toplists - how to?

  • 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.

pepper82

Member
Jan 26, 2017
272
1
18
41
Hi all,
as I am unable to find any working solution I would like to know if anybody else here knows a good solution for advanced toplists in skript?

Something like this:
Code:
add "player1" to {_score::}
add "player2" to {_score::}
add "player3" to {_score::*}
set {_score::emoji_stuck_out_tongue:layer1::score} to 15
set {_score::emoji_stuck_out_tongue:layer2::score} to 40
set {_score::emoji_stuck_out_tongue:layer3::score} to 10

set {_sorted::} to sorted list (sorted by value from high to low) {_score::}

loop {_sorted::*}:
message "%loop-index% = %loop-value%"

Can anybody help me with this? How would you do a good toplist in skript?
 
code_language.skript:
function sort(indices: strings, values: numbers, descending: boolean = true) :: strings:
    loop {_indices::*}:
        add 1 to {_f}
        set {_sort::%{_values::%loop-index%}%.%{_f}%} to loop-value
    return (reversed {_sort::*}) if {_descending} is true, else {_sort::*}

usage:
sort((indices of {kills::*}), {kills::*})
 
Status
Not open for further replies.