Toplist Position

  • 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 community!

    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.
I'm not stupid. I failed in my example with {Kills::*} and i forgot a ":" :emoji_slight_smile:

Maybe the problem is that my list is saved with player uuids not player names?
 
I'm not stupid. I failed in my example with {Kills::*} and i forgot a ":" :emoji_slight_smile:

Maybe the problem is that my list is saved with player uuids not player names?

I didn't said that , everyone can miss something.
Nah it's not , but you can do some test if you want to do.
 
@H0peLess What server version are you currently running, and what addons do you have installed currently?
 
Only numbers.
18-07-2017-1500389286.png

But with player names.
add 1 to {Kills:%attacker%}
Did you get this from the code i send you?
 
@H0peLess I ask because using RandomSK's number sorting expression would make this a rather trivial task, but unfortunately the plugin has not updated in some time, and the expression is not located within any other addon.

In addition, I believe the problem with @YoshYz's functions is that when a list variable is copied (like in a function argument), only its values are copied; not its indexies (the player UUIDs in our case). You can probably fix it by replacing all the function arguments with the actual variable.

I also made this code:

code_language.skript:
function generateList(reversed: boolean) :: objects:
    # sorting list via Skript's built in sorting function
    set {_topList::*} to sorted {Kills::*}
    # looping sorted list
    loop {_topList::*}:
        # looping kills 
        loop {Kills::*}:
            # if the value from the sorted list matches the value from the kills list
            "%loop-value-1%" is "%loop-value-2%"
            # reverse list if wanted
            if {_reversed} is true:
                set {_index} to ((amount of {Kills::*}) + 1) - ("%loop-index-1%" parsed as integer)
            else:
                set {_index} to loop-index-1
            # set the new sorted list's value to the player's uuid, with the correctly sorted index
            set {_topListTrue::%{_index}%} to loop-index-2
            exit loop
    return {_topListTrue::*}

function getRank(p: player) :: number:
    set {_topList::*} to generateList(true)
    loop {_topList::*}:
        "%loop-value%" is "%uuid of {_p}%"
        return "%loop-index%" parsed as number
    return 0

command /topList:
    trigger:
        # see functions above
        set {_topList::*} to generateList(true)
        # printing list to make sure it works
        loop {_topList::*}:
            message "%loop-index%, %loop-value%"
        # getting rank
        message "Rank: %getRank(player)%"

which is probably less efficient than the code YoshYz mentioned, but it gets the job done.
 
Hmm i just used this code:
code_language.skript:
Command /killtest:
    Trigger:
        add 1 to {Kills::%uuid of player%}
        Loop {Kills::*}:
            Broadcast "%loop-value%"
            Broadcast "%loop-index%"
And the broadcast loop-index part doesn't return any thing?
Maybe this has some thing to do with it?
Cuz it should return the uuid of the player right?
 
Hmm i just used this code:
code_language.skript:
Command /killtest:
    Trigger:
        add 1 to {Kills::%uuid of player%}
        Loop {Kills::*}:
            Broadcast "%loop-value%"
            Broadcast "%loop-index%"
And the broadcast loop-index part doesn't return any thing?
Maybe this has some thing to do with it?
Cuz it should return the uuid of the player right?

The expression add can be used for multiple things. Your current code seems like you're trying to add the value of 1 to the variable {Kills::%uuid of player%}. If this variable is not set to begin with, it will return null.

Secondly, the expression add can be used to add a value to a list. Such as add 1 to {Kills::*}
 
The expression add can be used for multiple things. Your current code seems like you're trying to add the value of 1 to the variable {Kills::%uuid of player%}. If this variable is not set to begin with, it will return null.

Secondly, the expression add can be used to add a value to a list. Such as add 1 to {Kills::*}
Yeah i am adding 1 to the player's kill counter each time and all off that works fine it will return the right values when i execute the command but the 'broadcast "%loop-index%"' part will just do nothing, it doesn't even say <none> and gives no errors.
So am i just making a mistake here or what is the problem?
 
Yeah i am adding 1 to the player's kill counter each time and all off that works fine it will return the right values when i execute the command but the 'broadcast "%loop-index%"' part will just do nothing, it doesn't even say <none> and gives no errors.
So am i just making a mistake here or what is the problem?

Hmm; that's odd. What skript/server versions are you running.

I used this this slightly edited command (only adding to clear the list to test things):

code_language.skript:
command /killtest:
    trigger:
        clear {Kills::*}
        add 1 to {Kills::%uuid of player%}
        Loop {Kills::*}:
            Broadcast "%loop-value%"
            Broadcast "%loop-index%"
And it seems to work fine on my side.
 
Hmm; that's odd. What skript/server versions are you running.

I used this this slightly edited command (only adding to clear the list to test things):

code_language.skript:
command /killtest:
    trigger:
        clear {Kills::*}
        add 1 to {Kills::%uuid of player%}
        Loop {Kills::*}:
            Broadcast "%loop-value%"
            Broadcast "%loop-index%"
And it seems to work fine on my side.
What does it broadcast? Does it broadcast the loop-index (uuid of player)?
 
What does it broadcast? Does it broadcast the loop-index (uuid of player)?

Yups; I'm too lazy to restart my server to get a screenshot, but I can post the snigbit from the log:
code_language.skript:
[12:51:41] [Server thread/INFO]: 1
[12:51:41] [Server thread/INFO]: 1841bd3e-a5d4-4d41-88e4-c3e7552541de
 
Yups; I'm too lazy to restart my server to get a screenshot, but I can post the snigbit from the log:
code_language.skript:
[12:51:41] [Server thread/INFO]: 1
[12:51:41] [Server thread/INFO]: 1841bd3e-a5d4-4d41-88e4-c3e7552541de
Hmm maybe the OP has the same problem
as me with the loop-index not being parsed.
So i will wait till @H0peLess posts his skript version and minecraft version.

For me it just parses:
code_language.skript:
18.07 22:16:08 [Server] INFO # /killtest
18.07 22:16:08 [Server] INFO 6
18.07 22:16:08 [Server] INFO # killtest took 1.988122 milliseconds
It says nothing about the loop-index
[doublepost=1500447243,1500408749][/doublepost]@H0peLess could you try this skript:
code_language.skript:
Set {_playerrank} to 1
Loop {Kills::*}:
    If loop-value > {Kills::%uuid of player}:
        Add 1 to {_playerrank}
[doublepost=1500561935][/doublepost]@H0peLess if your issue is solved please mark the thread as solved.
 
The List is a UUID list from all player tehy has allready a stats: (if you dont have stats it will be buggy)
This was for JumpAndRun and ist the smallest time not the biggest u must change this


{Jnr.Rekord.2.name.%loop-var%} = Players name (here is colored nickname)
{Jnr.Rekord.2.TTT.%loop-var%} = Stats as colored (for design)
{Jnr.Rekord.2.%loop-var-2%} = Stats vairbale

code_language.skript:
every 1 second:
    clear {Jnr.Stats.beste6::*}
    loop {Jnr.Platzt.2.List.::*}:
        add loop-var to {Jnr.Stats.beste6::*}
    wait 1 tick
    loop {Jnr.Stats.beste6::*}:
        set {jnr.rank.stats.%loop-var-1%} to 1
        loop {Jnr.Stats.beste6::*}:
            if loop-var-1 is not loop-var-2:
                if {Jnr.Rekord.2.%loop-var-1%} is bigger than {Jnr.Rekord.2.%loop-var-2%}:
                    add 1 to {jnr.rank.stats.%loop-var-1%}
                else:
                    if {Jnr.Rekord.2.%loop-var-1%} is {Jnr.Rekord.2.%loop-var-2%}:
                        add 1 to {jnr.rank.stats.%loop-var-1%}
    wait 1 tick
    loop {Jnr.Stats.beste6::*}:
           
        if {jnr.rank.stats.%loop-var%} is 1:
            set {Jnr.Platz.1.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.1} to colored {Jnr.Rekord.2.TTT.%loop-var%}

        if {jnr.rank.stats.%loop-var%} is 2:
            set {Jnr.Platz.2.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.2} to colored {Jnr.Rekord.2.TTT.%loop-var%}

        if {jnr.rank.stats.%loop-var%} is 3:
            set {Jnr.Platz.3.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.3} to colored {Jnr.Rekord.2.TTT.%loop-var%}

        if {jnr.rank.stats.%loop-var%} is 4:
            set {Jnr.Platz.4.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.4} to colored {Jnr.Rekord.2.TTT.%loop-var%}

        if {jnr.rank.stats.%loop-var%} is 5:
            set {Jnr.Platz.5.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.5} to colored {Jnr.Rekord.2.TTT.%loop-var%}

        if {jnr.rank.stats.%loop-var%} is 6:
            set {Jnr.Platz.6.Player} to colored "%{Jnr.Rekord.2.name.%loop-var%}%"
            set {Jnr.Platz.6} to colored {Jnr.Rekord.2.TTT.%loop-var%}
 
Last edited by a moderator:
Status
Not open for further replies.