Hi guys.
I'd like to make a type of system where whenever a DarkRP wallet amount goes over 999999, it changes to 1M or 1.00 M, and once it's over 999M it changes to 1B, and so on.
I think I'd start it somewhat like this?
[CODE]if LocalPlayer():getDarkRPVar("money") > 999999 then
--something goes here, not sure what
end[/CODE]
Found this with a google search...
[code]
local function ReadableNumber(num, places)
local ret
local placeValue = ("%%.%df"):format(places or 0)
if not num then
return 0
elseif num >= 1000000000000 then
ret = placeValue:format(num / 1000000000000) .. " Tril" -- trillion
elseif num >= 1000000000 then
ret = placeValue:format(num / 1000000000) .. " Bil" -- billion
elseif num >= 1000000 then
ret = placeValue:format(num / 1000000) .. " Mil" -- million
elseif num >= 1000 then
ret = placeValue:format(num / 1000) .. "k" -- thousand
else
ret = num -- hundreds
end
return ret
end
[/code]
All you need to do is adapt it, use this function to display money:
[code]ReadableNumber( LocalPlayer():getDarkRPVar( "money" ), 2 )[/code]
Where "2" is the number of decimal places.
Sorry, you need to Log In to post a reply to this thread.