code_language.skript:
options:
P : &6Stats &8| &7
A : &8➟&7
L: &8&m---------------------------
function loadStats(s: player, e: player):
set metadata tag "stats" of {_e} to chest inventory with 3 rows named "&8%{_s}%'s Stats"
set slot (all integers between 0 and 27) of metadata tag "stats" of {_e} to black stained glass pane named "&8&ka"
set {_k} to kill entity stat using {_s} for {_s}
set {_d} to deaths stat using {_s} for {_s}
set {_m} to format({_s}'s balance)
set {_playtime} to time format from time played of {_s}
set {_mb} to mob kills stat using {_s} for {_s}
set {_blocksplaced} to {Stats::BlockPlace::%uuid of {_s}%} ? 0
set {_blocksbroken} to {Stats::BlockBreak::%uuid of {_s}%} ? 0
set {_killsformatted} to killsformat({_k})
set {_bbformatted} to bbformat({_blocksbroken})
set slot 10 of metadata tag "stats" of {_e} to diamond sword with all flags hidden named "&b&lPLAYER KILLS" with lore "&fPlayer kills: &a%{_killsformatted}%"
set slot 11 of metadata tag "stats" of {_e} to skeleton skull with all flags hidden named "&7&lDEATHS" with lore "&fCurrent deaths: &a%{_d}%"
set slot 12 of metadata tag "stats" of {_e} to gold ingot with all flags hidden named "&e&lMONEY" with lore "&fMoney: &a$%{_m}%"
set slot 13 of metadata tag "stats" of {_e} to clock with all flags hidden named "&e&lPLAYTIME" with lore "&fCurrent playtime: &a%{_playtime}%"
set slot 14 of metadata tag "stats" of {_e} to zombie head with all flags hidden named "&2&lMOB KILLS" with lore "&fMob kills: &a%{_mb}%"
set slot 15 of metadata tag "stats" of {_e} to dirt block with all flags hidden named "<##B5825A>&lBLOCKS PLACED" with lore "&fBlocks placed: &a%{_blocksplaced}%"
set slot 16 of metadata tag "stats" of {_e} to diamond pickaxe with all flags hidden named "&b&lBLOCKS BROKEN" with lore "&fBlocks broken: &a%{_bbformatted}%"
open metadata tag "stats" of {_e} to {_e}
command /stats [<offlineplayer>]:
cooldown: 3 seconds#
cooldown message: {@P} &7Please wait &6%remaining time% &7until using this command again!
aliases: /stat
trigger:
if arg-1 is not set:
loadStats(sender, sender)
else if arg-1 is set:
loadStats(arg-1, sender)
on inventory click:
if event-inventory = (metadata tag "stats" of player):
cancel event
on block place:
add 1 to {Stats::BlockPlace::%uuid of player%}
on block break:
add 1 to {Stats::BlockBreak::%uuid of player%}
function killsformat(s: string) :: number:
set {_s} to {_s} in lower case
loop ("k|m|b|t|qa|qi|sx|sp|oc" split at "|"):
add 1 to {_i} if {_s} partially matches "(\d|\.)(k|m|b|t|qa|qi|sx|sp|oc)"
set {_z::*} to split {_s} at loop-value
replace all "," in {_z::1} with ""
{_z::1} does not partially match "[^.0-9]":
return ({_z::1} parsed as number) * (10 ^ ({_i} * 3))
return 0
function bbformat(bbs: string) :: number:
set {_bbs} to {_bbs} in lower case
loop ("k|m|b|t|qa|qi|sx|sp|oc" split at "|"):
add 1 to {_bbi} if {_bbs} partially matches "(\d|\.)(k|m|b|t|qa|qi|sx|sp|oc)"
set {_bbz::*} to split {_bbs} at loop-value
replace all "," in {_bbz::1} with ""
{_bbz::1} does not partially match "[^.0-9]":
return ({_bbz::1} parsed as number) * (10 ^ ({_bbi} * 3))
return 0
Posted by: inqy. from the skUnity Discord. View the thread on skUnity Discord here