Jump to content

Money Hud


Matevsz

Recommended Posts

Posted

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?

Posted
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 

Posted

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 

Posted
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 
  
  

My scripting skills

 


76561198189590622.pngAddFriend.png

Posted
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 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Edit:

See $0 and add player money see $54,454,454

124wlrs.jpg

and how to do so after the entry could be seen as:

15eqok.jpg

I have to enter a zero in dxDrawText?

Posted

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 

 DUyJ810.gif

Posted

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 

 DUyJ810.gif

Posted

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

Posted
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())) 

 DUyJ810.gif

Posted
  
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) 
  

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