Jump to content

Format currency


Recommended Posts

12 minutes ago, g1ps said:

Hello, how to make the currency format on the scoreboard ?
k 1.000
m 1.000.000

Here is a very clean, simple, useful code snippet which you can use all across your Skripts:

function formatNumber(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}%"

Once you have this in place, here is a simple example of quickly using this:

command /format <number>:
        send "%formatNumber(arg-1)%"

To test this out, use /format (number) and this should format the number for you.

In a similar manner, pass in your balance variable/expression into this and it will return you a formatted number.


Thanks to EWS for making it.

Here is the full thread, all credits go to EWS: https://forums.skunity.com/threads/useful-vanilla-skript-functions.7000/

  • Like 1

Hello there! If you're reading this, hope you're having a wonderful day!


Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.


Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...