List of players with most deaths descending

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

Cursinal

New Member
Sep 20, 2018
6
0
1
Hi, I have a skript which counts player's deaths and I wanted to add a command and if possible a scoreboard showing 5 players with most deaths descending. Here is my script:

Code:
on join:
    if {%player%.deaths} is not set:
        set {%player%.deaths} to 0
        
on death:
    if victim is a player:
        add 1 to {%player%.deaths}

command /deaths [<offline player>]:
    trigger:
        if arg 1 is not set:
            send "You have {%player%.deaths} deaths." to player
        else:
            send "%arg 1% has {%arg 1%.deaths} deaths." to player
 
if you want to help with list, you should make any :emoji_smiley: You can try this:
Code:
on death:
    if victim is a player:
        add 1 to {deaths::%victim%::*}
command /deaths [<offline player>]:
    trigger:
        if arg-1 is not set:
            send "You have %size of {deaths::%player%::*}% deaths." to player
        else:
            send "%arg-1% has %size of {deaths::%arg-1%::*}% deaths." to player
 
  • Like
Reactions: Cursinal
Code:
function reversed(list: objects) :: objects:
    loop size of {_list::*} times:
        set {_index} to size of {_list::*} - loop-number - 1
        add {_list::%{_index}%} to {_reversed::*}
    return {_reversed::*}

on join:
    if {deaths::%player's uuid%} is not set:
        set {deaths::%player's uuid%} to 0
       
on death:
    if victim is a player:
        add 1 to {deaths::%victim's uuid%}

command /deaths [<offline player>]:
    trigger:
        if arg-1 is not set:
            send "You have {deaths::%player's uuid%} deaths." to player
        else if arg-1 is "scoreboard":
            send " "
            send "          &a&lTop 5 Deaths" to player
            send "------------------------------------" to player
            loop all offline players:
                set {_this.add} to "%{death::%loop-offlineplayer's uuid%}%" parsed as integer 
                add {_this.add} to {_sorted::*}
                set {_this.player} to "%loop-offlineplayer%"
                add {_this.player} to {_sorted::*}
            set {_sorted::*} to sorted {_sorted::*}
            set {_sorted::*} to reversed({_sorted::*})
            loop {_sorted::*}:
                set {_int} to loop-index parsed as integer
                if {_int} > 10:
                    exit loop
                else if {_int} = 2 or 4 or 6 or 8 or 10:
                    set {_subtract} to ({_int} - 1)
                    send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%{_subtract}%}%" to player
            send "------------------------------------" to player
        else:
            send "%arg-1% has {deaths::%arg-1's uuid%} deaths." to player
 
Last edited:
I tested the skript today and it's not working:/ it gives me errors

Code:
[Skript] Reloading deaths.sk...
 Line 24: (deaths.sk)
 There's no loop that matches 'loop-player's uuid'
 Line: set {_this.add} to "%{death::%loop-player's uuid%}%" parsed as integer
 
 Line 26: (deaths.sk)
 There's no loop that matches 'loop-player'
 Line: set {_this.player} to "%loop-player%"
 
 Line 31: (deaths.sk)
 There's no loop that matches 'loop-index > 10'
 Line: if loop-index > 10:
 
 Line 33: (deaths.sk)
 'else if' has to be placed just after another 'if' or 'else if' section
 Line: else if loop-index = 2 or 4 or 6 or 8 or 10:
 
 Line 13: (deaths.sk)
 Use 'attacker' and/or 'victim' in damage/death events
 Line: add 1 to {deaths::%player's uuid%}
 
I tested the skript today and it's not working:/ it gives me errors

Code:
[Skript] Reloading deaths.sk...
 Line 24: (deaths.sk)
 There's no loop that matches 'loop-player's uuid'
 Line: set {_this.add} to "%{death::%loop-player's uuid%}%" parsed as integer
 
 Line 26: (deaths.sk)
 There's no loop that matches 'loop-player'
 Line: set {_this.player} to "%loop-player%"
 
 Line 31: (deaths.sk)
 There's no loop that matches 'loop-index > 10'
 Line: if loop-index > 10:
 
 Line 33: (deaths.sk)
 'else if' has to be placed just after another 'if' or 'else if' section
 Line: else if loop-index = 2 or 4 or 6 or 8 or 10:
 
 Line 13: (deaths.sk)
 Use 'attacker' and/or 'victim' in damage/death events
 Line: add 1 to {deaths::%player's uuid%}
oh nah, hold up
 
I tested the skript today and it's not working:/ it gives me errors

Code:
[Skript] Reloading deaths.sk...
 Line 24: (deaths.sk)
 There's no loop that matches 'loop-player's uuid'
 Line: set {_this.add} to "%{death::%loop-player's uuid%}%" parsed as integer
 
 Line 26: (deaths.sk)
 There's no loop that matches 'loop-player'
 Line: set {_this.player} to "%loop-player%"
 
 Line 31: (deaths.sk)
 There's no loop that matches 'loop-index > 10'
 Line: if loop-index > 10:
 
 Line 33: (deaths.sk)
 'else if' has to be placed just after another 'if' or 'else if' section
 Line: else if loop-index = 2 or 4 or 6 or 8 or 10:
 
 Line 13: (deaths.sk)
 Use 'attacker' and/or 'victim' in damage/death events
 Line: add 1 to {deaths::%player's uuid%}
oops I forgor
 
I tested the skript today and it's not working:/ it gives me errors

Code:
[Skript] Reloading deaths.sk...
 Line 24: (deaths.sk)
 There's no loop that matches 'loop-player's uuid'
 Line: set {_this.add} to "%{death::%loop-player's uuid%}%" parsed as integer
 
 Line 26: (deaths.sk)
 There's no loop that matches 'loop-player'
 Line: set {_this.player} to "%loop-player%"
 
 Line 31: (deaths.sk)
 There's no loop that matches 'loop-index > 10'
 Line: if loop-index > 10:
 
 Line 33: (deaths.sk)
 'else if' has to be placed just after another 'if' or 'else if' section
 Line: else if loop-index = 2 or 4 or 6 or 8 or 10:
 
 Line 13: (deaths.sk)
 Use 'attacker' and/or 'victim' in damage/death events
 Line: add 1 to {deaths::%player's uuid%}
okay, I edited the code, try again
 
Thanks for you effort! It fixed some of the issues but there still are two errors left:/

Code:
[Skript] Reloading deaths.sk...
Line 31: (deaths.sk)
loop-index is already a text, so you should not put it in one (e.g. loop-index instead of "%loop-index%")
Line: set {_int} to "%loop-index%" parsed as integer
 
Line 35: (deaths.sk)
There's no loop that matches 'loop-index - 1'
Line: send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%loop-index - 1%}%" to player
 
Line 13: (deaths.sk)
Use 'attacker' and/or 'victim' in damage/death events
Line: add 1 to {deaths::%player's uuid%}
 
I changed {deaths::%player's uuid%} to {deaths::%victim's uuid%} and error at line 13 is gone. Btw can I change %player's uuid% to %player%? My server isn't online and I think that might be better option
 
Thanks for you effort! It fixed some of the issues but there still are two errors left:/

Code:
[Skript] Reloading deaths.sk...
Line 31: (deaths.sk)
loop-index is already a text, so you should not put it in one (e.g. loop-index instead of "%loop-index%")
Line: set {_int} to "%loop-index%" parsed as integer
 
Line 35: (deaths.sk)
There's no loop that matches 'loop-index - 1'
Line: send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%loop-index - 1%}%" to player
 
Line 13: (deaths.sk)
Use 'attacker' and/or 'victim' in damage/death events
Line: add 1 to {deaths::%player's uuid%}
Oopie
 
I changed {deaths::%player's uuid%} to {deaths::%victim's uuid%} and error at line 13 is gone. Btw can I change %player's uuid% to %player%? My server isn't online and I think that might be better option
No, not really, bc if the player changes their name it would reset their death count.
 
so, what about this one, any ideas?

Code:
Line 35: (deaths.sk)
There's no loop that matches 'loop-index - 1'
Line: send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%loop-index - 1%}%" to player
 
so, what about this one, any ideas?

Code:
Line 35: (deaths.sk)
There's no loop that matches 'loop-index - 1'
Line: send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%loop-index - 1%}%" to player
yes, me have idea.

Code:
set {_loop-index} to "%loop-index%" parsed as integer # This should work, if not just remove the " "%%" " around loop-index
set {_subtract} to ({_loop-index} - 1)
send "&a%{_sorted::%loop-index%}% &3- &a%{_sorted::%{_subtract}%}%" to player

I will edit my post with these changes in a second.

P.S. I fixed it, along with the rest of the errors there were before. There should be no more errors left.