Migins Posted May 1, 2020 Share Posted May 1, 2020 (edited) 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 May 1, 2020 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) Link to comment Share on other sites More sharing options...
nicholxs Posted June 3, 2020 Share Posted June 3, 2020 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 2015VIP: January 2020Jr.Mod: 1st April 2020Mod: 16th July 2020Info:~ Skript Developer ~ Discord: @nicholxs#0001 ~ Previous names: Nichxlxs, Deterno, iHaveSkills, Retrical Link to comment Share on other sites More sharing options...
Endgator Posted June 3, 2020 Share Posted June 3, 2020 damn that's same nice looking skript ¯\_(ツ)_/¯ Link to comment Share on other sites More sharing options...
AnonymousUser Posted June 3, 2020 Share Posted June 3, 2020 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 More sharing options...
Theleast47 Posted April 15, 2021 Share Posted April 15, 2021 E Link to comment Share on other sites More sharing options...
thistl Posted April 15, 2021 Share Posted April 15, 2021 @Theleast47 please do not comment on threads over 1 month old!Locked for Necroposting Discord: thistle#1234In Game: thistlMinehut Community Support Member (8/10/19) Minehut Junior Moderator(10/30/19)Minehut Moderator(12/30/19 - 07/11/20) Reinstated (09/19/20)(05/19/21) Link to comment Share on other sites More sharing options...
Recommended Posts