How to sort things in list variables?

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

Padlick

Member
Jan 26, 2017
33
1
8
22
Hey Guys. I tried the way with RandomSK
code_language.skript:
set {Kills::Mirre} to 12
set {Kills::Bla} to 10
set {Kills::What} to 5
 
set {Toplist::*} to sorted {Kills::*} from highest to lowest
message "Top Kills:"
loop {Toplist::*}:
    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)
 
Yes. There is this error:
code_language.skript:
[14:24:00 ERROR]: #!#! Current node: null
[14:24:00 ERROR]: #!#! Current item: set {Toplist::*}(as java.lang.Object) to sorted list
 
The Stack trace:
code_language.skript:
[14:23:59] [Server thread/ERROR]: #!#! Stack trace:
[14:23:59] [Server thread/ERROR]: #!#! ch.njol.skript.SkriptAPIException: UnparsedLiterals must be converted before use
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.UnparsedLiteral.invalidAccessException(UnparsedLiteral.java:275)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.UnparsedLiteral.getAll(UnparsedLiteral.java:285)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.expressions.ExprSortedList.get(ExprSortedList.java:69)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:105)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.effects.EffChange.execute(EffChange.java:270)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Effect.run(Effect.java:54)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:65)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:93)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Trigger.execute(Trigger.java:53)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:222)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:184)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands.handleCommand(Commands.java:270)
[14:23:59] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.Commands$1.onPlayerCommand(Commands.java:165)
[14:23:59] [Server thread/ERROR]: #!#!     at sun.reflect.GeneratedMethodAccessor153.invoke(Unknown Source)
[14:23:59] [Server thread/ERROR]: #!#!     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[14:23:59] [Server thread/ERROR]: #!#!     at java.lang.reflect.Method.invoke(Method.java:498)
[14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
[14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
[14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
[14:23:59] [Server thread/ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1127)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:970)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[14:24:00] [Server thread/ERROR]: #!#!     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[14:24:00] [Server thread/ERROR]: #!#!     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:718)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:367)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657)
[14:24:00] [Server thread/ERROR]: #!#!     at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560)
[14:24:00] [Server thread/ERROR]: #!#!     at java.lang.Thread.run(Thread.java:745)
 
If you looking around Script section there is a Top list without addons required.
code_language.skript:
command /ranking:
    trigger:
        loop {Kills::*}:
            add 1 to {_size}
            if {_low.to.high.list::%loop-value%} is not set:
                set {_low.to.high.list::%loop-value%} to loop-index
            else:
                set {_n} to 0
                loop {_size} times:
                    set {_n} to {_n}+1
                    {_low.to.high.list::%loop-value-1%.%{_n}%} is not set
                    set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
                    stop loop
        wait 1 tick
        set {_n} to size of {_low.to.high.list::*}
        loop {_low.to.high.list::*}:
            set {_high.to.low.list::%{_n}%} to loop-value
            set {_n} to {_n}-1
        wait 1 tick
        set {_i} to 0
#THIS IS THE MESSAGE WITH TOP KILLS
        send "&7&m-----------&8< &6Top10 &8>&7&m-----------"
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            send "&7%{_topnumber}% - &c%{_player}% &8» &7%{Kills::%loop-value%}% Kills"
            add 1 to {_i}
            if {_topnumber} > 10: #this is top 10 you can change it
                stop
        send "&7&m------------------------------"
 
If you looking around Script section there is a Top list without addons required.
code_language.skript:
command /ranking:
    trigger:
        loop {Kills::*}:
            add 1 to {_size}
            if {_low.to.high.list::%loop-value%} is not set:
                set {_low.to.high.list::%loop-value%} to loop-index
            else:
                set {_n} to 0
                loop {_size} times:
                    set {_n} to {_n}+1
                    {_low.to.high.list::%loop-value-1%.%{_n}%} is not set
                    set {_low.to.high.list::%loop-value-1%.%{_n}%} to loop-index
                    stop loop
        wait 1 tick
        set {_n} to size of {_low.to.high.list::*}
        loop {_low.to.high.list::*}:
            set {_high.to.low.list::%{_n}%} to loop-value
            set {_n} to {_n}-1
        wait 1 tick
        set {_i} to 0
#THIS IS THE MESSAGE WITH TOP KILLS
        send "&7&m-----------&8< &6Top10 &8>&7&m-----------"
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            send "&7%{_topnumber}% - &c%{_player}% &8» &7%{Kills::%loop-value%}% Kills"
            add 1 to {_i}
            if {_topnumber} > 10: #this is top 10 you can change it
                stop
        send "&7&m------------------------------"

Thanks Dude :emoji_grinning:
 
@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..
 
Last edited by a moderator:
code_language.skript:
    loop {SortedList::*}:
        set {_player} to "%loop-value%" parsed as offlineplayer
        if {UnsortedList::%loop-value%} is not 0:
            add 1 to {_topnumber}
            broadcast "{@prefixw} &7%{_topnumber}% &8» {@normal}%{_player}% &8» {@value}%{UnsortedList::%loop-value%}%"
            add 1 to {_i}
            if {_topnumber} is {_playersonline}: #this is top 10 you can change it
                exit loop
 
Status
Not open for further replies.