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!
You can always check out skUnity Downloads for downloads and any other information about Skript!
How to make 1000 to 1k
Like
1000 = 1k
1000000 = 1M
1000000000 = 1B
1000000000000 = 1T
1000000000000000 = 1Qn
1000000000000000000 = 1Qi
1000000000000000000000 = 1Sx
set {_balance} to player's balance
if {_balance} is between 1000 and 9999:
send "&aYour balance is: %first character of {_balance}%K"
else if {_balance} is between 10000 and 99999:
send "&aYour balance is: %first 2 characters of {_balance}%K"
else if {_balance} is between 100000 and 999999:
send "&aYour balance is: %first 3 characters of {_balance}%K"
else if {_balance} is between 1000000 and 9999999:
send "&aYour balance is: %first character of {_balance}%M"
#And you do that up to the limit number.
That is wrong. Because in the variable you wrote:and the numbers are the same format.Code:if {test} is 1000: set {test} to "1k"
if {test} is 1000:
set {test} to "1K"
set {_bal} to balance of player
if {_bal} is between 1000 and 999999:
set {_new} to "%{_bal}/1000%K"
else if {_bal} is between 1000000 and 999999999:
set {_new} to "%{_bal}/1000000%M"
#etc
message {_new} to player
set {_bew} to balence of player
if {_bew} is between 1000 and 999999;
set {_new} to "%{_bew}/1000%K"
function formatNum(n: number) :: string:
set {_l::*} to split "k,M,B,T,Qn,Qi,Sx" at ","
set {_i} to min(floor(log({_n})/3), size of {_l::*})
return "%{_n}%" if {_i} <= 0
set {_i2} to 1000^{_i}
return "%{_n}/{_i2}%%{_l::%{_i}%}%"
set {_v::*} to 1000, 1000000, 1000000000
set {_n::*} to "K", "M" and "B"
set {_b} to balance of player
loop {_v::*}:
{_b} > loop-value
set {_r} to "%{_b} / loop-value%%{_n::%loop-index%}%"
send "&aBalance: &c%{_r}%"
Mine is more efficientthis is much more efficient:
code_language.skript:set {_v::*} to 1000, 1000000, 1000000000 set {_n::*} to "K", "M" and "B" set {_b} to balance of player loop {_v::*}: {_b} > loop-value set {_r} to "%{_b} / loop-value%%{_n::%loop-index%}%" send "&aBalance: &c%{_r}%"
Yea def more efficient. Usually things without loops are more efficient in my opinion.I think
would workcode_language.skript:function formatNum(n: number) :: string: set {_l::*} to split "k,M,B,T,Qn,Qi,Sx" at "," set {_i} to min(floor(log({_n})/3), size of {_l::*}) return "%{_n}%" if {_i} <= 0 set {_i2} to 1000^{_i} return "%{_n}/{_i2}%%{_l::%{_i}%}%"