Discord Thread Number Problems

  • 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 community!

    Now, what are you waiting for? Join the community now!

This thread came from the skUnity Discord. You can't reply to it here but if you join the skUnity Discord, you'll be able to post a reply there. The thread link is part of the thread's message.
Status
Not open for further replies.

skUnity Discord

Site Manager
Aug 5, 2023
12,749
1
0
The skUnity Discord
discord.gg
code_language.skript:
vb
function pMCUPG(p: player):
    set {_u} to {_p}'s uuid
    
    send action bar "&cYou do not have enough money!" to {_p} if {balance::%{_u}%} < 10
    {balance::%{_u}%} >= 10
    set {_n} to floor({balance::%{_u}%}/10)
    remove abs({_n}*10) from {balance::%{_u}%}
    add {_n} to {mpc::%{_u}%}
    send "&7You have recieved &e+%fN({_n})% MPC&7 for &a$%fN({_n}*10)%&7." to {_p}
If someone's balance is too high it will max the amount of mpc they can get at the 64-bit integer limit.

Posted by: RandomUser336545 from the skUnity Discord. View the thread on skUnity Discord here
 
Well you have a condition filtering out things below 10… somethings not right
Also if n is negative, you remove the abs(n) from the balance, but add n (no absolute value!) to the mpc
Would the balance be negative?
Nvm then it would say you dont have enough

Posted by: x8ight from the skUnity Discord.
 
yea math stops mathing at big numbers, you could write a script to create big numbers with scientific notations basically. saving the balance as as decimal of 10 places for example then having a seperate value for how many zeroes are behind it. 10 decimal places for accuracy and the seperate value can be used for big numbers up to 64 byte limit so 18 billion zeroes. though it might be difficult to implement with math you can probably find some implementations of it in different languages so just translate it into skript
in short: for big numbers implement math with decimal + zero count
1 thousand would be 1 as the decimal and 3 as the zero count 1e3
1234 would be 1.234 + 3 zeroes

Posted by: tommyfoxs from the skUnity Discord.
 
code_language.skript:
function multiplyBigNumber(big1: text, big2: text) :: text:#number can be 1e2 or 1e900 etc
    set {_value1::*} to {_big1} split at "e"
    set {_value2::*} to {_big2} split at "e"
    set {_decimal} to 1st element of {_value1::*} parsed as a number * 1st element of {_value2::*} parsed as a number
    set {_zeroes} to 2nd element of {_value1::*} parsed as a number + 2nd element of {_value2::*} parsed as a number
    return normalizeBigNumber("%{_decimal}%e%{_zeroes}%")
    
function normalizeBigNumber(big: text) :: text:
    set {_values::*} to {_big} split at "e"
    set {_decimal} to first element of {_values::*} parsed as a number
    if {_decimal}  is greater than 10:
        set {_zeroes} to 2nd element of {_values::*} parsed as a number
        while {_decimal} is greater than 10:
            set {_decimal} to {_decimal}/10
            add 1 to {_zeroes}
        return "%{_decimal}%e%{_zeroes}%"
    else:
        return {_big}
probably a bad explanation that i made but i dont really care so sure. this is all i can do. normalization turns 10e2 to 1e3 and 25e1 to 2.5e2 for example. if you want to show pretty numbers you can just get the zero count of the notation and then use a list with indices to check a suitable prefix like 1e3 can be shown as 1k if {test::3} is set to "k" etc.

Posted by: tommyfoxs from the skUnity Discord.
 
Status
Not open for further replies.