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

How to sort things in list variables?

Discussion in 'Skript' started by Padlick, May 14, 2017.

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

    Padlick Active Member

    Joined:
    Jan 26, 2017
    Messages:
    33
    Likes Received:
    1
    Hey Guys. I tried the way with RandomSK
    Code (Skript):
    1. set {Kills::Mirre} to 12
    2. set {Kills::Bla} to 10
    3. set {Kills::What} to 5
    4.  
    5. set {Toplist::*} to sorted {Kills::*} from highest to lowest
    6. message "Top Kills:"
    7. loop {Toplist::*}:
    8.     message "%loop-index%: %loop-value%"
    But it doesn't work. I get a "Internal error occured while..."

    I am on a minigame where you are drawing and the others have to think about what it is and get points for this.
    At the end there is the points of view, this is what I want to sort, but I don't know how :emoji_frowning:

    (Sorry for my bad english, I am german and not so good in other languages)
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Are there errors in the Console?
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Yes. There is this error:
    Code (Skript):
    1. [14:24:00 ERROR]: #!#! Current node: null
    2. [14:24:00 ERROR]: #!#! Current item: set {Toplist::*}(as java.lang.Object) to sorted list
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    The whole errorlog should be a bit longer
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    The Stack trace:
    Code (Skript):
    1. [14:23:59] [Server thread/ERROR]: #!#! Stack trace:
    2. [14:23:59] [Server thread/ERROR]: #!#! ch.njol.skript.SkriptAPIException: UnparsedLiterals must be converted before use
    3. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.UnparsedLiteral.invalidAccessException(UnparsedLiteral.java:275)
    4. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.UnparsedLiteral.getAll(UnparsedLiteral.java:285)
    5. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.expressions.ExprSortedList.get(ExprSortedList.java:69)
    6. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:105)
    7. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.effects.EffChange.execute(EffChange.java:270)
    8. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Effect.run(Effect.java:54)
    9. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65)
    10. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93)
    11. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Trigger.execute(Trigger.java:53)
    12. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:222)
    13. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:184)
    14. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands.handleCommand(Commands.java:270)
    15. [14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:165)
    16. [14:23:59] [Server thread/ERROR]: #!#!     at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
    17. [14:23:59] [Server thread/ERROR]: #!#!     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    18. [14:23:59] [Server thread/ERROR]: #!#!     at java.lang.reflect.Method.invoke(Method.java:498)
    19. [14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
    20. [14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    21. [14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
    22. [14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
    23. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1127)
    24. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:970)
    25. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
    26. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
    27. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
    28. [14:24:00] [Server thread/ERROR]: #!#!     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    29. [14:24:00] [Server thread/ERROR]: #!#!     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    30. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19)
    31. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:718)
    32. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:367)
    33. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657)
    34. [14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560)
    35. [14:24:00] [Server thread/ERROR]: #!#!     at java.lang.Thread.run(Thread.java:745)
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Try updating RandomSK: Downloads

    Works fine using:
    - RandomSK 2.7.1
    - Bensku's Skript fork: dev-25
    - PaperSpigot for 1.11.2 (Paper-1079)
     
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Nope. It doesn't work for me.
    I'm am using:
    - RandomSK 2.7.1
    - Bensku's Skript fork: dev-25
    - Spigot for 1.8.6 (R0.1)
     
  8. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    If you looking around Script section there is a Top list without addons required.
    Code (Skript):
    1. command /ranking:
    2.     trigger:
    3.         loop {Kills::*}:
    4.             add 1 to {_size}
    5.             if {_low.to.high.list::%loop-value%} is not set:
    6.                 set {_low.to.high.list::%loop-value%} to loop-index
    7.             else:
    8.                 set {_n} to 0
    9.                 loop {_size} times:
    10.                     set {_n} to {_n}+1
    11.                     {_low.to.high.list::%loop-value-1%.%{_n}%} is not set
    12.                     set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
    13.                     stop loop
    14.         wait 1 tick
    15.         set {_n} to size of {_low.to.high.list::*}
    16.         loop {_low.to.high.list::*}:
    17.             set {_high.to.low.list::%{_n}%} to loop-value
    18.             set {_n} to {_n}-1
    19.         wait 1 tick
    20.         set {_i} to 0
    21. #THIS IS THE MESSAGE WITH TOP KILLS
    22.         send "&7&m-----------&8< &6Top10 &8>&7&m-----------"
    23.         loop {_high.to.low.list::*}:
    24.             add 1 to {_topnumber}
    25.             set {_player} to "%loop-value%" parsed as offlineplayer
    26.             send "&7%{_topnumber}% - &c%{_player}% &8» &7%{Kills::%loop-value%}% Kills"
    27.             add 1 to {_i}
    28.             if {_topnumber} > 10: #this is top 10 you can change it
    29.                 stop
    30.         send "&7&m------------------------------"
     
  9. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Thanks Dude :emoji_grinning:
     
    • Friendly Friendly x 1
  10. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Here you go :emoji_grinning:
     
  11. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    @CrisisLP There is only one problem.. if someone has 0 points, and there 2 two players online, the second one who has more than 0 points is twice in the chat..
     
    #11 ShaneBee, May 17, 2017
    Last edited by a moderator: May 17, 2017
  12. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Hmm can you send picture. Cant imagine.
     
  13. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
  14. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    What send out %loop-value% and %loop-index% ?
     
  15. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    Code (Skript):
    1.     loop {SortedList::*}:
    2.         set {_player} to "%loop-value%" parsed as offlineplayer
    3.         if {UnsortedList::%loop-value%} is not 0:
    4.             add 1 to {_topnumber}
    5.             broadcast "{@prefixw} &7%{_topnumber}% &8» {@normal}%{_player}% &8» {@value}%{UnsortedList::%loop-value%}%"
    6.             add 1 to {_i}
    7.             if {_topnumber} is {_playersonline}: #this is top 10 you can change it
    8.                 exit loop
     
  16. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    This would loop chaos. This would not classified.
     
  17. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,123
    Likes Received:
    158
    @CrisisLP I used the code that you have send me, but only a bit modified
     
Thread Status:
Not open for further replies.
Loading...