FlapKakker Posted August 31, 2021 Share Posted August 31, 2021 Hello there! Glad you stumbled upon this post hehe! I'm currently trying to make a leaderboard for my players. It should sort the players based on their prestige and within that list, sorted based on their level. I'm already able to sort based on one list, but I can't figure out how to sort the levels inside the sorted prestige list! You can find my code snippet to sort based on levels down below. Thanks in advance if you can help me out! Example of what i need: (i know it should be uuid, but havent had time to change all my files yet  ) (dont mind the layout) - Prestige top: #1 Verwarmingman: P:15 Lvl:54 #2 ezezez: P:10 Lvl:89 #3 Notch: P:3 Lvl:11 #4 ElPepe: P:1 Lvl:30 #5 ggfds: P:0 Lvl:5 Example of what I currently have: - Level top: #1 ezezez: Lvl:89 #2 Verwarmingman: Lvl:54 #3 ElPepe: Lvl:30 #4 Notch: Lvl:11 #5 ggfds: Lvl:5  #levels loop {level::*}: add 1 to {_size2} if {_low.to.high.list.levels::%loop-value%} is not set: set {_low.to.high.list.levels::%loop-value%} to loop-index else: set {_n2} to 0 loop {_size2} times: set {_n2} to {_n2}+1 {_low.to.high.list.levels::%loop-value-1%.%{_n2}%} is not set set {_low.to.high.list.levels::%loop-value-1%.%{_n2}%} to loop-index stop loop wait 1 tick set {_n2} to size of {_low.to.high.list.levels::*} loop {_low.to.high.list.levels::*}: set {_high.to.low.list.levels::%{_n2}%} to loop-value set {_n2} to {_n2}-1 wait 1 tick  Link to comment Share on other sites More sharing options...
emopediaMC Posted August 31, 2021 Share Posted August 31, 2021 https://skripthub.net/docs/?id=3542https://skripthub.net/docs/?id=3544https://skripthub.net/docs/?id=2158 function sort(indices: strings, values: numbers, descending: boolean = true) :: strings:   loop {_indices::*}:     set {_sort::%{_values::%loop-index%}%.%loop-index%} to loop-value   return (reversed {_sort::*}) if {_descending} is true, else {_sort::*} Hi! You can use what I have linked above to accomplish this. This requires skript-holo and thats all (pretty sure, its late and im not thinking.) Developer  Joined Minecraft in 2010 on PC Joined Minehut in August 2016 1 year Skript experience 2 months Java experience 5 months Javascript experience  Link to comment Share on other sites More sharing options...
itsKimo Posted August 31, 2021 Share Posted August 31, 2021 u should probably count the persons levels in a total variable like {totallevel.%player's uuid%} because if ur making a leaderboard for levels ppl lose levels on rebirth im assuming Link to comment Share on other sites More sharing options...
emopediaMC Posted September 1, 2021 Share Posted September 1, 2021 8 hours ago, itsKimo said: {totallevel.%player's uuid%} ew nested vars Developer  Joined Minecraft in 2010 on PC Joined Minehut in August 2016 1 year Skript experience 2 months Java experience 5 months Javascript experience  Link to comment Share on other sites More sharing options...
pnguin Posted September 1, 2021 Share Posted September 1, 2021 5 hours ago, emopediaMC said: ew nested vars ikr I used to play Minehut I guess? Yeah, I still watch the forums for some reason. (15/5/2023) Link to comment Share on other sites More sharing options...
FlapKakker Posted September 2, 2021 Author Share Posted September 2, 2021 On 8/31/2021 at 10:55 PM, itsKimo said: u should probably count the persons levels in a total variable like {totallevel.%player's uuid%} because if ur making a leaderboard for levels ppl lose levels on rebirth im assuming indeed ieuw nested vars haha, and thanks for the reply! They indeed reset upon prestiging, but still counting the total doesnt enable me to sort within the sorted prestige list :s  Link to comment Share on other sites More sharing options...
FlapKakker Posted September 8, 2021 Author Share Posted September 8, 2021 For anyone still looking for the solution, I dont know if anyone even is lol, you can find it down below #levels loop {prestige::*}: add 1 to {_size2} if {_low.to.high.list.levels::%loop-value%} is not set: set {_low.to.high.list.levels::%loop-value%} to loop-index else: set {_n2} to 0 loop {_size2} times: set {_n2} to {_n2}+1 {_low.to.high.list.levels::%loop-value-1%.%{_n2}%} is not set set {_low.to.high.list.levels::%loop-value-1%.%{_n2}%} to loop-index stop loop wait 1 tick set {_n2} to size of {_low.to.high.list.levels::*} loop {_low.to.high.list.levels::*}: set {_high.to.low.list.levels::%{_n2}%} to loop-value set {_n2} to {_n2}-1 wait 1 tick #loop second time loop {_high.to.low.list.levels::*}: add 1 to {_size4} set {_player} to "%loop-value%" parsed as offline player set {_level} to {level::%{_player}%} set {_prestige} to {prestige::%{_player}%} if {_low.to.high.list.levels2::%{_prestige}%.%{_level}%} is not set: set {_low.to.high.list.levels2::%{_prestige}%.%{_level}%} to loop-value #broadcast "no %{_low.to.high.list.levels2::%{_prestige}%.%{_level}%}%" #broadcast "%{_level}%" else: set {_n4} to 0 loop {_size4} times: set {_n4} to {_n4}+1 {_low.to.high.list.levels2::%{_prestige}%.%{_level}%.%{_n4}%} is not set set {_low.to.high.list.levels2::%{_prestige}%.%{_level}%.%{_n4}%} to loop-value-1 #broadcast "yes %{_low.to.high.list.levels2.%{_prestige}%.%{_level}%.%{_n4}%}%" #broadcast "%{_level}%" stop loop wait 1 tick set {_n5} to size of {_low.to.high.list.levels2::*} loop {_low.to.high.list.levels2::*}: set {high.to.low.list.levels2::%{_n5}%} to loop-value set {_n5} to {_n5}-1 wait 1 tick #message set {_topnumber} to 0 set {_ind2} to 0 loop {high.to.low.list.levels2::*}: #broadcast "%{_high.to.low.list.levels2::%loop-index%}% eeee" add 1 to {_ind2} if {_ind2} < 6: add 1 to {_topnumber} set {_player} to "%loop-value%" parsed as offlineplayer #broadcast "%{_player}% player" make console execute command "/holo setline leveltop %{_ind2} + 2% &d##%{_topnumber}% &f%{_player}% &f- &fP:%{prestige::%loop-value%}%&f Lvl. %{level::%loop-value%}%" #broadcast "%{_ind2}% %{_ind2} + 2%" else: make console execute command "/holo reload leveltop" stop loop + keep in mind that you CANNOT/SHOULDNT run this every second or on a command! When many people join your server, the list variables will be huge and looping over them will take considerable resources. You should make a timed event (e.g.: 30 minutes) and announce in chat that lagg may occur whilst loading the new leaderboards  Link to comment Share on other sites More sharing options...
itsKimo Posted September 15, 2021 Share Posted September 15, 2021 On 9/1/2021 at 1:38 AM, emopediaMC said: ew nested vars ouch Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now