# 1000 TO 1K

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

Not open for further replies.
1. ### Narek7445 Member

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

#1
2. ### Joni Member

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

#2
3. ### couger44 Supporter

Joined:
Feb 19, 2017
Messages:
395
13
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
Last edited: May 13, 2019
• Like x 1
4. ### novastosha Well-Known Member

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

#4
5. ### Revelationage Well-Known Member

Joined:
Jan 27, 2017
Messages:
115
11
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

#5
6. ### novastosha Well-Known Member

Joined:
Jan 11, 2019
Messages:
105
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"

#6
7. ### TPGamesNL Well-Known Member

Joined:
Jan 20, 2018
Messages:
1,217
70
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
Last edited: May 16, 2019
• Useful x 2
8. ### ExtremeUltra Member

Joined:
May 10, 2019
Messages:
15
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}%"

#8
9. ### TPGamesNL Well-Known Member

Joined:
Jan 20, 2018
Messages:
1,217
70
Medals:
Mine is more efficient

#9
10. ### Revelationage Well-Known Member

Joined:
Jan 27, 2017
Messages:
115
11
Yea def more efficient. Usually things without loops are more efficient in my opinion.

#10
• Agree x 1
11. ### ExtremeUltra Member

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

#11