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!


    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.

Top 10 in a gui

Discussion in 'Skript' started by Hassan7000, Jul 1, 2018.

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

    Hassan7000 Member

    Mar 12, 2018
    Likes Received:
    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
  2. uGim

    uGim Member

    Jan 19, 2018
    Likes Received:
    Code (Skript):
    1. command /topcookies:
    2.     trigger:
    3.         set {_tmp::*} to {cookies::*}
    4.         set {_top} to 0
    5.         send "Top players:" to player
    6.         loop 10 times:
    7.             loop {_tmp::*}:
    8.                 if loop-value-2 > {_top}:
    9.                     set {_top} to loop-value-2
    10.                     set {_ind} to loop-index
    11.             send "Score: %{_top}%" to player
    12.             delete {_tmp::%{_ind}%}
    13.             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.
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    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 (Skript):
    1. command /topcookies:
    2.     trigger:
    3.         open virtual chest inventory with size 4 named "&3TOP COOKIES" to player
    4.         loop {cookies::*}:
    5.             set {_tmp::%loop-index%} to loop-value
    6.         set {_top} to 0
    7.         set {_slot} to 9                # ----- Where you want the top cookies to start in the gui
    8.         loop 10 times:
    9.             loop {_tmp::*}:
    10.                 if loop-value-2 > {_top}:
    11.                     set {_top} to loop-value-2
    12.                     set {_ind} to loop-index
    13.             set {_player} to cookie named "&b%{_ind}%" with lore "&7Cookies: &a%{_top}%"
    14.             format gui slot {_slot} of player with {_player}
    15.             add 1 to {_slot}
    16.             delete {_tmp::%{_ind}%}
    17.             set {_top} to 0
Thread Status:
Not open for further replies.

Share This Page