1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

formated number function request

Discussion in 'Requests' started by titustitus98, Jun 25, 2019.

Tags:
  1. titustitus98

    titustitus98 Member

    Joined:
    Feb 19, 2018
    Messages:
    46
    Likes Received:
    0
    Category: Function

    Suggested name:
    format.sk
    Spigot/Skript Version:
    1.12.2
    What I want:
    What I need is a function to format number (1k, 1m, 1b...)

    Ideas for commands:
    none
    Ideas for permissions:
    none
    When I'd like it by: A couple days
     
  2. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    Use
    Code (Text):
    1. function formatNum(n: number) :: string:
    2.     set {_l::*} to split "k,M,B,T,Qn,Qi,Sx" at ","
    3.     set {_i} to min(floor(log({_n})/3), size of {_l::*})
    4.     return "%{_n}%" if {_i} <= 0
    5.     set {_i2} to 1000^{_i}
    6.     return "%{_n}/{_i2}%%{_l::%{_i}%}%"
    (from here)
     

Share This Page

Loading...