Jump to content

Skript Baltop


Migins

Recommended Posts

Hi,

I have noticed a lot of topics about Skript Baltop's but none actually contained much skript itself.

I am requesting help on how to create a balance top skript. I am using my own variables as currency ({bal::%player's uuid%}).

If any of you are willing to send me in the right direction or help at all I would appreciate it 🙂

Spoiler

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------------------------------"

This is a skript I found online however I don't understand it and I don't think it does what I want (send player and the balance of them)

 

Edited by Migqy

Support  July 29, 2020 → November 3, 2020

► Helper November 3, 2020 → February 22, 2021

► Moderator February 22, 2021 → May 17, 2021

 I might not always respond to forum dms, however I am always contactable on discord (mig#0069)

Screen Shot 2020-03-20 at 5.23.33 pm.png

Link to comment
Share on other sites

  • 1 month later...

Okay, let's start
 

        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

Essentially, this whole system sorts the variable list, in this case {Kills::*} into descending order (from largest number to smallest). This works with just vanilla skript, but if you want to compact it, Morkaz has a nice one line way of doing this. (though, in vanilla you could sort it then reverse it, but personally I prefer morkaz' format way)

set {_list::*} to sorted {Kills::*} from highest to lowest with format "@index"

Essentially, this lists them from highest to lowest with the format "@index", meaning it's the number on the list (for example, {_list::1}). You could also format it like "@index: $@value", but you could play around with it more.

Anyways, now that you have this sorted list, you want to loop it and for the first 10 people broadcast it (then stop after that), which is essentially what the last bit of code does

        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------------------------------"

 

First Joined: July 2015
VIP: January 2020
Jr.Mod: 1st April 2020
Mod: 16th July 2020

Info:

~ Skript Developer
~ Discord: @nicholxs#0001
~ Previous names: Nichxlxs, Deterno, iHaveSkills, Retrical

Link to comment
Share on other sites

There really is not a good way of sorting in vanilla skript, even the way above will crash your server if your list variable has a large amount of values, I don't know why the developers haven't bothered to add a sorting expression yet because forcing skripters to do it themselves (on minehut without skript-mirror) is an awful idea due to how greatly skript loops impact performance.

Link to comment
Share on other sites

  • 10 months later...
  • thistl locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...