Solved This can be shorter ?

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

Uzumaki

Well-Known Member
Feb 20, 2017
310
10
18
code_language.skript:
sub "winner":
    loop {bg::gamekills::*}:
        if loop-value is more than {_1st.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to {_2nd}
            set {_3rd.point} to {_2nd.point}
            set {_2nd} to {_1st}
            set {_2nd.point} to {_1st.point}
            set {_1st} to loop-index
            set {_1st.point} to loop-value
        else if loop-value is more than {_2nd.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to {_2nd}
            set {_3rd.point} to {_2nd.point}
            set {_2nd} to loop-index
            set {_2nd.point} to loop-value
        else if loop-value is more than {_3rd.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to loop-index
            set {_3rd.point} to loop-value
        else if loop-value is more than {_4th.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to loop-index
            set {_4th.point} to loop-value
        else if loop-value is more than {_5th.point}:
            set {_5th} to loop-index
            set {_5th.point} to loop-value
    broadcast "%{_1st}% %{_1st.point}%"
 
code_language.skript:
sub "winner":
    loop {bg::gamekills::*}:
        if loop-value is more than {_1st.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to {_2nd}
            set {_3rd.point} to {_2nd.point}
            set {_2nd} to {_1st}
            set {_2nd.point} to {_1st.point}
            set {_1st} to loop-index
            set {_1st.point} to loop-value
        else if loop-value is more than {_2nd.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to {_2nd}
            set {_3rd.point} to {_2nd.point}
            set {_2nd} to loop-index
            set {_2nd.point} to loop-value
        else if loop-value is more than {_3rd.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to {_3rd}
            set {_4th.point} to {_3rd.point}
            set {_3rd} to loop-index
            set {_3rd.point} to loop-value
        else if loop-value is more than {_4th.point}:
            set {_5th} to {_4tlmg}
            set {_5th.point} to {_4th.point}
            set {_4tlmg} to loop-index
            set {_4th.point} to loop-value
        else if loop-value is more than {_5th.point}:
            set {_5th} to loop-index
            set {_5th.point} to loop-value
    broadcast "%{_1st}% %{_1st.point}%"

There are some people that can create it smaller but this is what i came up with.

{_list::1} contains point of player in first place
{_list2::1} contains player in first place
{_list::2} contains point of player in second place
{_list2::2} contains player in second place
ETC

this will do it for all players in the list not just the first 5

code_language.skript:
sub "winner":
    set {_counter} to 0
    loop {bg::gamekills::*}:
        add 1 to {_counter}
    loop {bg::gamekills::*}:
        set {_backup::%loop-index%} to loop-value
    loop {_counter} times:
        delete {_first.player}
        delete {_first.number}
        loop {_backup::*}:
            if {_first.player} is not set:
                set {_first.number} to loop-value-2
                set {_first.player} to loop-index
            else:
                if loop-value-2 > {_first.number}:
                    set {_first.number} to loop-value-2
                    set {_first.player} to loop-index
        add {_first.number} to {_list::*}
        add {_first.player} to {_list2::*}
        delete {_backup::%{_first.player}%}
#Display part
    set {_loop} to 1
    loop {_counter} times:
        broadcast "%{_loop}%: %{_list2::%{_loop}%}% %{_list::%{_loop}%}%"
        add 1 to {_loop}
 
sorry but I forgot to mention because i need only the 1st player and his points at final. this is why i wanted make it shorter.
 
Last edited by a moderator:
randomsk has a number sorting expression

or if you dont want to use that this is what i came up with
code_language.skript:
set {_highest_kills} to 0
loop {bg::gamekills::*}:
    if loop-value is greater than {_highest_kills}:
        set {_highest_kills} to loop-value
        set {_highest_killer} to loop-index
broadcast "%{_highest_killer}% - %{_highest_kills}%"
 
randomsk has a number sorting expression

or if you dont want to use that this is what i came up with
code_language.skript:
set {_highest_kills} to 0
loop {bg::gamekills::*}:
    if loop-value is greater than {_highest_kills}:
        set {_highest_kills} to loop-value
        set {_highest_killer} to loop-index
broadcast "%{_highest_killer}% - %{_highest_kills}%"
Thanks again.
 
Nice example but how could you output the TOP 5 players with most kills ?
 
Nice example but how could you output the TOP 5 players with most kills ?
If you're talking about my example then you could just loop that code 5 times and at the end of the inner loop (outside of it but inside the outer loop) remove {_highest_killer} from the list
 
Status
Not open for further replies.