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!

  2. LOOKING FOR A VERSION OF SKRIPT??:

    You can always check our our Wiki for downloads and any other information about Skript!

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

1000 TO 1K

Discussion in 'Skript' started by Narek7445, May 12, 2019.

  1. N

    Narek7445 Member

    Joined:
    May 12, 2019
    Messages:
    1
    Likes Received:
    0
    How to make 1000 to 1k
    Like
    1000 = 1k
    1000000 = 1M
    1000000000 = 1B
    1000000000000 = 1T
    1000000000000000 = 1Qn
    1000000000000000000 = 1Qi
    1000000000000000000000 = 1Sx
     
  2. J

    Joni Member

    Joined:
    Jan 5, 2019
    Messages:
    17
    Likes Received:
    0
    Code (Text):
    1. if {test} is 1000:
    2.     set {test} to "1k"
    and the numbers are the same format.
     
  3. couger44

    Supporter

    Joined:
    Feb 19, 2017
    Messages:
    312
    Likes Received:
    10
    Code (Skript):
    1.  
    2. set {_balance} to player's balance
    3. if {_balance} is between 1000 and 9999:
    4.     send "&aYour balance is: %first character of {_balance}%K"
    5. else if {_balance} is between 10000 and 99999:
    6.     send "&aYour balance is: %first 2 characters of {_balance}%K"
    7. else if {_balance} is between 100000 and 999999:
    8.     send "&aYour balance is: %first 3 characters of {_balance}%K"
    9. else if {_balance} is between 1000000 and 9999999:
    10.     send "&aYour balance is: %first character of {_balance}%M"
    11. #And you do that up to the limit number.
    12.  
    --- Double Post Merged, May 13, 2019, Original Post Date: May 13, 2019 ---
    That is wrong. Because in the variable you wrote:
    Code (Skript):
    1. if {test} is 1000:
    but after you wrote the variable as text:
    Code (Skript):
    1. set {test} to "1K"
     
    #3 couger44, May 13, 2019
    Last edited: May 13, 2019
    • Like Like x 1
  4. novastosha

    novastosha Well-Known Member

    Joined:
    Jan 11, 2019
    Messages:
    66
    Likes Received:
    5
    Code (Text):
    1. if {he} is "G"
     
  5. Revelationage

    Revelationage Well-Known Member

    Joined:
    Jan 27, 2017
    Messages:
    101
    Likes Received:
    7
    This is how I always did it:

    Code (Skript):
    1. set {_bal} to balance of player
    2. if {_bal} is between 1000 and 999999:
    3.     set {_new} to "%{_bal}/1000%K"
    4. else if {_bal} is between 1000000 and 999999999:
    5.     set {_new} to "%{_bal}/1000000%M"
    6. #etc
    7. message {_new} to player
     
  6. novastosha

    novastosha Well-Known Member

    Joined:
    Jan 11, 2019
    Messages:
    66
    Likes Received:
    5
    Code (Text):
    1. set {_bew} to balence of player
    2. if {_bew} is between 1000 and 999999;
    3.     set {_new} to "%{_bew}/1000%K"
     
  7. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,020
    Likes Received:
    60
    Medals:
    I think
    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}%}%"
    would work
     
    #7 TPGamesNL, May 16, 2019
    Last edited: May 16, 2019
    • Useful Useful x 1
  8. ExtremeUltra

    ExtremeUltra Member

    Joined:
    May 10, 2019
    Messages:
    15
    Likes Received:
    0
    this is much more efficient:
    Code (Skript):
    1. set {_v::*} to 1000, 1000000, 1000000000
    2. set {_n::*} to "K", "M" and "B"
    3. set {_b} to balance of player
    4. loop {_v::*}:
    5.     {_b} > loop-value
    6.     set {_r} to "%{_b} / loop-value%%{_n::%loop-index%}%"
    7. send "&aBalance: &c%{_r}%"
     
  9. T

    TPGamesNL Well-Known Member

    Joined:
    Jan 20, 2018
    Messages:
    1,020
    Likes Received:
    60
    Medals:
    Mine is more efficient :emoji_stuck_out_tongue:
     
  10. Revelationage

    Revelationage Well-Known Member

    Joined:
    Jan 27, 2017
    Messages:
    101
    Likes Received:
    7
    Yea def more efficient. Usually things without loops are more efficient in my opinion.
     
    • Agree Agree x 1
  11. ExtremeUltra

    ExtremeUltra Member

    Joined:
    May 10, 2019
    Messages:
    15
    Likes Received:
    0
    alright lel .^. i just use the one i sent all the time so idk lel
     
Loading...