Skip to content

Instantly share code, notes, and snippets.

@Snow-Pyon
Created June 30, 2018 15:16
Show Gist options
  • Save Snow-Pyon/be373eb881101ecce3d4a7c13333d46e to your computer and use it in GitHub Desktop.
Save Snow-Pyon/be373eb881101ecce3d4a7c13333d46e to your computer and use it in GitHub Desktop.
options:
baltop-format: <light red>[position]<yellow>. [balance] <light grey> - <cmd:/baltop [player]>[player] # I suck at coloring so you may change this
highlight-top: 3 # The position and their balance's color will be changed to them
highlight-color: <light green>
on skript load:
codeblock {eco::baltop::sort}:
async:
set {_top-board::*} to {eco::balance::*}
set {_indexes::*} to indexes of {eco::balance::*}
loop size of {_top-board::*} times:
set {_index} to 1
loop {_top-board::*}:
add 1 to {_index}
set {_next} to {_top-board::%{_indexes::%{_index}%}%}
loop-value-2 is less than {_next}
{_index} is less or equal to size of {_top-board::*}
set {_top-board::%{_indexes::%{_index}%}%} to loop-value-2
set {_top-board::%loop-index%} to {_next}
if mod(loop-number, 20) is 0: # it waits one tick per 20 values looped, I'd increase it the bigger the variable is.
async wait 1 tick
codeblock {eco::baltop::format}:
sync:
set {_format} to {@baltop-format}
loop {_top-board::*}:
add 1 to {_position}
set {_format} to {@baltop-format}
set {_name} to "%loop-index parsed as offline player%"
replace all "[player]" with {_name} in {_format}
replace all "[position]" with "%{_position}%" in {_format}
replace all "[balance]" with "%loop-value%" in {_format}
if {_position} is less than or equal to {@highlight-top}:
set {_format} to "{@highlight-color}%subtext of {_format} from 2 to length of {_format}%"
if first character of format is "§":
set {_format} to "{@highlight-color}%subtext of {_format} from 2 to length of {_format}%"
else:
set {_format} to "{@highlight-color}%{_format}%"
set {eco-cache::baltop::%loop-index%} to {_format}
run codeblock {eco::baltop::sort} and {eco::baltop::format} in a chain
set {eco::baltop::last-sort} to now
command /balancetop [<offline player>]:
usage: /baltop [player]
description: Shows the users with most balance in the server; the top-list of the given player if provided. The list is updated once a day.
permission: skeco.baltop
permission message: <light red>You do not have the permission to use this command.
aliases: baltop
trigger:
if argument isn't set:
loop {eco-cache::baltop::*}:
send {_format} to sender
if {eco::baltop::last-sort} was more than a day ago:
run codeblock {eco::baltop::sort} and {eco::baltop::format} in a chain
else:
if argument hasn't played before in the server:
send "<yellow>Couldn't find the player in the database!"
stop
set {_uuid} to uuid of argument
if {eco-cache::baltop::%{_uuid}%} isn't set:
send "<yellow>Couldn't find the player in the database!"
stop
set {_format} to {@baltop-format}
set {_position-index} to first index of "[position]" in {_format}
set {_position} to subtext of {eco-cache::baltop::%{_uuid}%} from {_position-index} to {_position-index} + 1
send "<light green>%argument% Top Info" and ""
send "<yellow>Position<grey>: <light grey>%{_position}%"
send "<light green>Balance<grey>: <light grey>%{eco::balance::%{_uuid}%}%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment