Top 10 in a gui

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

Hassan7000

Member
Mar 12, 2018
23
3
0
24
Hey guys im making a cookieclicker the only thing i need is a top 10 over how many cookies players have. But i have no idea how i will do it so if anyone would like to help me would be great.

Im using this veriable to store the cookies {cookies::%player%}

Thank you
 
code_language.skript:
command /topcookies:
    trigger:
        set {_tmp::*} to {cookies::*}
        set {_top} to 0
        send "Top players:" to player
        loop 10 times:
            loop {_tmp::*}:
                if loop-value-2 > {_top}:
                    set {_top} to loop-value-2
                    set {_ind} to loop-index
            send "Score: %{_top}%" to player
            delete {_tmp::%{_ind}%}
            set {_top} to 0

So I got it to sort the scores from highest to lowest with math but found myself too lazy to make it with player names in GUI. I hope this helps somehow and there might be some other more simple way to do it than this because all I did is math.
 
I was trying to work on this yesterday but couldn't figure out the sorting.
Thank you @uGim for doing the math part, that's where I got stuck
So here is how you do the GUI part, you will need TuSke for the GUI

code_language.skript:
command /topcookies:
    trigger:
        open virtual chest inventory with size 4 named "&3TOP COOKIES" to player
        loop {cookies::*}:
            set {_tmp::%loop-index%} to loop-value
        set {_top} to 0
        set {_slot} to 9                # ----- Where you want the top cookies to start in the gui
        loop 10 times:
            loop {_tmp::*}:
                if loop-value-2 > {_top}:
                    set {_top} to loop-value-2
                    set {_ind} to loop-index
            set {_player} to cookie named "&b%{_ind}%" with lore "&7Cookies: &a%{_top}%"
            format gui slot {_slot} of player with {_player}
            add 1 to {_slot}
            delete {_tmp::%{_ind}%}
            set {_top} to 0
 
Status
Not open for further replies.