Format player balance in scoreboard

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Wynandus

Member
Aug 23, 2017
15
0
0
24
Hello there, so i was wondering if i could format the balance in the scoreboard since my economy on my server is a bit high and it will easily go into the millions i was wondering how i could format it.
code_language.skript:
every 5 seconds in "main":
    loop all players:
        if {scoreboard.player.%uuid of loop-player%} is not set:
            wipe loop-player's sidebar
            set {balace.%loop-player%} to "%loop-player's balance%"

            set {_prefix.%uuid of loop-player%} to "%colored loop-player's prefix%"
            replace all "(" and ")" with "" in {_prefix.%uuid of loop-player%}

            set name of sidebar of loop-player to "&d&lSERVER &7(Prison)"
            set score "&8&m---------------------" in sidebar of loop-player to 10
            set score "&d&lPlayer Information" in sidebar of loop-player to 9
            set score " &d&l* &7Name: &f%loop-player%" in sidebar of loop-player to 8
            if {balace.%loop-player%} is less than or equal to 999999:
                set {balace.%loop-player%} to {balace.%loop-player%} / 1000
                set score " &d&l* &7Balance: &f%{balace.%loop-player%}%k" in sidebar of loop-player to 7
            if {balance.%loop-player%} is more than 999999:
                set {balace.%loop-player%} to {balace.%loop-player%} / 1000000
                set score " &d&l* &7Balance: &f%{balace.%loop-player%}%k" in sidebar of loop-player to 7
            set score " &d&l* &7Tokens: &f%{token.balance.%uuid of loop-player%}%" in sidebar of loop-player to 6

            set score "&f" in sidebar of loop-player to 5

            set score "&d&lServer Information" in sidebar of loop-player to 4
            set score " &d&l* &7Online: &f%number of all players%" in sidebar of loop-player to 3
            set score " &d&l* &7Server IP: &f(/adress)" in sidebar of loop-player to 2
            set score "&8&m---------------------&f" in sidebar of loop-player to 1
        if {scoreboard.player.%uuid of loop-player%} is set:
            stop
this is not working
 
Last edited:
Just do a function that shortens a certain number of numbers ... there is a post
https://forums.skunity.com/threads/useful-vanilla-skript-functions.7000/
Here you will find the function you are looking for
code_language.skript:
function format(n: number) :: text:
   set {_data} to "QT,18|Q,15|T,12|B,9|M,6|k,3"
   loop split {_data} at "|":
       set {_s::*} to split loop-value at ","
       {_n} >= 10 ^ {_s::2} parsed as number
       return "%{_n} / 10 ^ {_s::2} parsed as number%%{_s::1}%"
   return "%{_n}%"
when you add this code ..... you analyze the amount like this:
%format({balance.% loop-player%})%
and it stays like that ....
set score " &d&l* &7Balance: &f%format({balance.%loop-player%})%" in sidebar of loop-player to 7
 
Status
Not open for further replies.