Abbreviating leaderboard cash number

You should definitely look at Miners Haven open source code; I was just looking at it… it’s called the MoneyLib and does exactly what you’re looking for be warned it is Copyrighted so therefore you’ll have to fork it and study it prior to rebooting your own releases

eh well it looks confusing if u don’t understand it

Its really that return line and me not knowing what log10 means and it just sounds bad to use for some reason lol.

it’s copyrighted and opensourced? never heard that before :joy:
anyways, i’ll check it out later

Just because its opensourced it doesn’t mean it’s not copyrighted. You can be opensourced but still cost money (My projects and Red hat). Open sourced means people can see the source and learn from it, copyrighted means that its illegal to steal it.

2 Likes

Here you go here is a good way.

local Suffixes = {"", "K", "M", "B", "T", "QA", "QI", "SX", "SP", "OC", "NO", "DC", "UD", "DD", "TD", "QAD", "QID", "SXD", "SPD", "OCD", "NOD", "VG", "UVG"}

function abbreviateNumber (n)
	local s = tostring(math.floor(n))
	return string.sub(s, 1, ((#s - 1) % 3) + 1) .. (Suffixes)[math.floor((#s - 1) / 3) + 1]
end

This was found via this Devforum post by @ABHI1290

Depending if there is a maximum amount of cash you’d like players to have then you can probably get rid of a few of the suffixes I don’t think players what have 1 Septillion cash (Assuming that’s what SP means)

I have another problem tho, how do i implement this in the game?
So like do i edit something in the main lb script or do i add another script?

Just go like

Text = abbreviateNumber(AmountOfMoneyPlayerHas)

Like this?

Yeah, I think so! Test it and see if it works.

image

May I see what statsname is? It should be a number of the amount of money you’ve got.

image

abbreviateNumber(AmountOfMoneyPlayerHas)

In between the ( ) should be the money you have. So a number not a string.

Yea, i put the abbreviate in the wrong part of the script :sweat_smile:

Thank you so much for helping, hope you have a good day!

You’re welcome! My day is now over and I’m now in bed lol! Thank you though.

Is the code working?

1 Like

Yes, it does, i put the abbreviate in the wrong part of the script, but when i fixed that it started working.

Ahh ok. I’m glad I could help!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.