TopKills from YAML stats?

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

ImMathi

Member
Jan 26, 2017
30
0
0
23
Hello.
I'm admin on one of the biggest kitpvp server's in denmark.
Our stats is saved in YML files, but i wanna make top 10 killers, but how do i do that
 
You need to get the amount of kills from the yml player and put this variable {kills.%name of player%}

Remember: Use {kills::%name of player%} If you use {kills::%player%} Will return none

code_language.skript:
on death of player:
    set {kills::%name of attacker%} to value "Stats.%attacker%.Kills" get of "plugins/KitPVP/stats.yml"

code_language.skript:
command /top:
    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--------------TOP KILLS---------------"
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            send "&7%{_topnumber}% - &e%{_player}% &7with &9%{kills::%loop-value%}% Kills"
            add 1 to {_i}
            if {_topnumber} > 10: #this is top 10 you can change it
                stop
        send "&7--------------TOP KILLS---------------"

RESULT
03BSRhE.png
 
You need to get the amount of kills from the yml player and put this variable {kills.%name of player%}

Remember: Use {kills::%name of player%} If you use {kills::%player%} Will return none

code_language.skript:
on death of player:
    set {kills::%name of attacker%} to value "Stats.%attacker%.Kills" get of "plugins/KitPVP/stats.yml"

code_language.skript:
command /top:
    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--------------TOP KILLS---------------"
        loop {_high.to.low.list::*}:
            add 1 to {_topnumber}
            set {_player} to "%loop-value%" parsed as offlineplayer
            send "&7%{_topnumber}% - &e%{_player}% &7with &9%{kills::%loop-value%}% Kills"
            add 1 to {_i}
            if {_topnumber} > 10: #this is top 10 you can change it
                stop
        send "&7--------------TOP KILLS---------------"

RESULT
03BSRhE.png
%player% returns the name of a player. Not "none"
 
The point of using YAML is haveing less variables...
So i do not want to get stats variables.
The {kills::%player%} that @FilipeNock suggested is pointless, all you need to do is loop through all nodes / values and set a local variable to the kill amount then sort it. The local variables get deleted after it is done...
 
Status
Not open for further replies.