Jump to content
Sign in to follow this  
l1j

Making a lag-free /top balance command

Recommended Posts

I currently have code that is working fine and all, but everytime the command is run it loops the variable and could easily crash the server if someone were to spam it. I was wondering if anyone knew an alternate way to do this so that it didn't lag the server if someone spammed it but still worked fine.

command /top balance:
  trigger:
    loop {money::*}:
      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
    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$%format({money::%loop-value%})%"
      add 1 to {_i}
      if {_topnumber} > 10:
        stop
    send "&7&m------------------------------"

 

Share this post


Link to post
Share on other sites

use morkazSK


  • Been "Skripting" for half a year now
  • Whale type 
  • Doesn't like Idle Servers (But made one)
  • Doesn't like Mining-PvP servers (But made one)
  • Likes MrScopes lol

 

I make original memes about minehut too.

Capture.png.5a3e6c2c283f3e0ee17860d8704f25f6.png

 

  • Discord Swayl#4299
  • MC IGN - Swayl

Share this post


Link to post
Share on other sites
command /killtop [<text>]:
    aliases:kt
    trigger:
        set {_top} to 5

        send ""
        send " &b&lKill top &3(Top 5 Killers)"
        send ""
        set {_top::*} to sorted {kills::*} from highest to lowest with format "@index" # Assuming {kills::%uuid of player%} is your kills variable
        loop {_top::*}:
            add 1 to {_n}

            set {_p} to "%loop-value%" parsed as offline player
            set {_player} to {_p}'s uuid

            send " &3(##%{_n}%) &b%{_p}% &3(%{kills::%{_player}%}% kills)"

            if {_n} is {_top}:
                stop loop

        send ""

 


  • Been "Skripting" for half a year now
  • Whale type 
  • Doesn't like Idle Servers (But made one)
  • Doesn't like Mining-PvP servers (But made one)
  • Likes MrScopes lol

 

I make original memes about minehut too.

Capture.png.5a3e6c2c283f3e0ee17860d8704f25f6.png

 

  • Discord Swayl#4299
  • MC IGN - Swayl

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  



×
×
  • Create New...