Jump to content

Money Hud


Matevsz

Recommended Posts

Hi, I created hud money with pennies. After loading shows $00.00 instead of $000000.00

  
function HudMoney() 
    local money = string.format("%.2f", getPlayerMoney(getLocalPlayer())) 
    dxDrawText("$"..money.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false)  
end 
  

And after entering 25.50, gives us the same 25

whether it is a bad string.format?

Link to comment
function HudMoney() 
    local money = string.format ( "%09d", getPlayerMoney ( getLocalPlayer ( ) ) ) 
    dxDrawText("$"..money.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 

Link to comment

Try that,

function HudMoney() 
    local money = string.format ( "%.8f", getPlayerMoney ( getLocalPlayer ( ) ) ) 
    dxDrawText("$"..money.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 

Link to comment
function HudMoney() 
   local cash = getPlayerMoney(getLocalPlayer()) 
    money = "$"..convertNumber(cash) 
    dxDrawText("$"..money.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 
  
function convertNumber ( number ) 
    local formatted = number 
    while true do 
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1.%2") 
        if ( k==0 ) then 
            break 
        end 
    end 
    return formatted 
end 
  
  

Link to comment
function HudMoney() 
    local cash = getPlayerMoney(getLocalPlayer()) 
    dxDrawText("$"..formatNumber(cash).."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 
  
  
function formatNumber(n) 
    if (not n) then return "Error catching data" end 
    local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$') 
    return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right 
end 

Link to comment

try this

function convertNumber ( number ) 
    local formatted = number 
    while true do 
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1.%2") 
        if ( k==0 ) then 
            break 
        end 
    end 
    return formatted 
end 
  
function HudMoney() 
    local money = string.format ( "%.8f", getPlayerMoney ( getLocalPlayer ( ) ) ) 
    dxDrawText("$"..convertNumber(money).."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 

Link to comment

or try this

function convertNumber ( number ) 
    local formatted = number 
    while true do 
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", "%1.%2") 
        if ( k==0 ) then 
            break 
        end 
    end 
    return formatted 
end 
  
function HudMoney() 
    local money2 = getPlayerMoney(getLocalPlayer()) 
    local money = string.format ( "%.8f", getPlayerMoney ( getLocalPlayer ( ) ) ) 
if money2 < -0 then 
    dxDrawText("$"..money2.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
else 
dxDrawText("$"..convertNumber(money).."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
end 
end 

Link to comment
I would like to x6 ordinary money and pennies together x2 (.00) = $000000.00 and only a pittance without dividing into $000,000,000

you tried to adjust the string of numbers of string?

local variable = "%011d" -- add number  03 or 02 EX: "%0 03 d"  
local money1 = string.format(variable, getPlayerMoney(getLocalPlayer())) 

Link to comment
  
local money = string.format("%.2f", getPlayerMoney(getLocalPlayer())) 
    dxDrawText("$"..money.."", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
  

See $0.00 Now add the rest of the digits "0"?

29p3zux.png

Gui Editor:

  
dxDrawText("$", 1455, 53, 1478, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1474, 53, 1497, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1493, 53, 1516, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1512, 53, 1535, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1531, 53, 1554, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1550, 53, 1573, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1569, 53, 1592, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText(".", 1588, 53, 1611, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1598, 53, 1621, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
dxDrawText("0", 1617, 53, 1640, 86, tocolor(255, 255, 255, 255), 1.50, "pricedown", "left", "top", false, false, false, false, false) 
  

Link to comment

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...