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!

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

[solved] Sorting list variables. (for ranking script?

Discussion in 'Addon Suggestions' started by FuwariYurayura, Feb 22, 2017.

  1. FuwariYurayura

    Joined:
    Feb 16, 2017
    Messages:
    8
    Likes Received:
    0
    Actually, it is possible to create ranking script without any addon. (Like below)
    However, if the data became too big, such script cause heavy heavy lag. (That is fatal!! ;(

    So my suggestion is addon which has sorting functions.

    (Or anyone know how to create the faster ranking system, only using existing addon?)
    I really wish if I could sort variables in faster way.....

     
    #1 FuwariYurayura, Feb 22, 2017
    Last edited: Feb 23, 2017
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Do you want to suggest an expression to addon but without using any addon?
    RandomSK used to have this expression, but Bensku's fork has the same one to do this job.
    Code (Skript):
    1. sorted %objects% #returns a list of objects sorted from lower to highest value
    2.  
    3. #Example
    4. set {_top::*} to sorted {TopPlayers::*}
    But the problem is that this expression doesn't return the indexes, only values.
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Plz, use format code... that looks so ugly xD
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    I fixed. :emoji_stuck_out_tongue:

    I need to sort not only values but indexes, to create ranking.
    Therefore that example has big problem....
    (I forgot to tell that I have already tried RandomSK)

    The function I need is sorting value with indexes kept.
    Anyone can create the new addon or add the new function to existing addons?
     
    #4 ShaneBee, Feb 23, 2017
    Last edited by a moderator: Feb 23, 2017
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Hi.
    I managed to find out how to make faster ranking script.
    And, it does not require any addons!

    So addon with a sorting fuction might be unnecessary anymore :O
    I will also post this revolutionary script to RESOURCES/Scripts. :emoji_slight_smile:

    Thx Tuke_nuke,PuchiGFX.

    Code (Skript):
    1.  
    2.  
    3. on load:
    4.     set {_players} to 0
    5.     loop {kd.kills::*}:
    6.         if loop-value is greater than 0.5:
    7.             add 1 to {_numberofplayers}
    8.             add 1 to {_topkillsexist::%loop-value%}
    9.             set {_topkillsvalue::%loop-value%::%loop-index%} to loop-index
    10.     set {_processnumber} to {_numberofplayers}
    11.     loop {_topkillsexist::*}:#I used double loop
    12.         loop {_topkillsvalue::%loop-index%::*}:       # (But I don't know why it works well)
    13.             set {temp.topkills::%{_processnumber}%} to loop-value-2 #index = uuid
    14.             remove 1 from {_processnumber}
    15.     message "Created Ranking of %{_players}% players." to console
    16.     set {temp.topkills.NumberOfPlayers} to {_numberofplayers}
    17.  
    18. # * If you want sort a decimal number, try multiplying x100000  and  then rounding.
    19. # e.g)    set {_kdr::%loop-index%} to (rounded down (10000*{kd.kills::%loop-index%})) / loop-value
    20.  
    21. command /topkills [<number>]:
    22.     usage: &b/topkills (pages)
    23.     trigger:
    24.         set {_totalpages} to rounded up {temp.topkills.NumberOfPlayers} / 10
    25.         if {_totalpages} is 0:
    26.             message "&b-=-=-=-=- Kill Ranking =-=-=-=-"
    27.             message "&3There is no data to list...."
    28.             stop
    29.         broadcast "%{_totalpages}%"
    30.         if arg-1 exist:
    31.             if arg-1 is greater than {_totalpages}:
    32.                 set {_target} to {_totalpages}
    33.             else if arg-1 is smaller than 1:
    34.                 set {_target} to 1
    35.             else:
    36.                 set {_target} to rounded down arg-1
    37.         else:
    38.             set {_target} to 1
    39.         set {_start} to (10*{_target}) -9
    40.         if (9+{_start}) is greater than {temp.topkills.NumberOfPlayers}:
    41.             set {_looptimes} to {temp.topkills.NumberOfPlayers} - {_start} + 1
    42.         else:
    43.             set {_looptimes} to 10
    44.         message "&b-=-=-=-=- Kill Ranking =-=-=-=-"
    45.         loop {_looptimes} times:
    46.             message "&b%{_start}%: %{player.lastknownname::%{temp.topkills::%{_start}%}%}%      %{kd.kills::%{temp.topkills::%{_start}%}%}% Kills"
    47.             add 1 to {_start}
    48.         message "&3Viewing page %{_target}%/%{_totalpages}%."
    49.  
    50. on death:
    51.     if attacker exist:
    52.         add 1 to {kd.kills::%attacker's uuid%}
    53.     broadcast "%{kd.kills::%attacker's uuid%}-1% --> %{kd.kills::%attacker's uuid%}%"
    54.  
    55. on join:
    56.     if {player.lastknownname::%player's uuid%} does not exist:
    57.         set {player.lastknownname::%player's uuid%} to player's name
    58.     else if {player.lastknownname::%player's uuid%} is not player's name:
    59.         set {player.lastknownname::%player's uuid%} to player's name
    60.  
    61.  
     
    #5 ShaneBee, Feb 25, 2017
    Last edited by a moderator: Feb 26, 2017

Share This Page

Loading...