Jump to content

[Help]Format money


sckatchof

Recommended Posts

Posted

hi guys how can make the money show like this on scoreboard : $ x.xxx.xxx

server side :

addEventHandler("onClientRender",getRootElement(), 
    function() 
        if not starttick then 
            starttick = getTickCount() 
        end 
        currenttick = getTickCount() 
        if currenttick - starttick >= 1000 then 
            setElementData(player, "Money" , "$"..getPlayerMoney( player ) ) 
            starttick =  getTickCount() 
        end 
    end 
)       

Posted

http://lua-users.org/wiki/FormattingNumbers

function format(n) 
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') 
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right 
end 

Example:

format( getPlayerMoney( player ) ) 

P.S. This function is not mine.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

No problem.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...