Jump to content

Ajuda Com Numero Decimal


Recommended Posts

Boa tarde :)

 

Eu to editando um sistema de hud cujo aparece a porcentagem de vida do jogador, porem, dependendo da porcentagem da vida do jogador aparece (73,1568431) queria saber se tem algum jeito de retirar os numeros que vem depois da virgula?

 

Quem puder ajudar, já agradeço ❤️

Link to comment
2 minutes ago, MesaDowN said:

Poste sempre seu código.

    local Nivel = getElementData ( localPlayer, "Level" ) or 0
	local Dinheiro_Mao = getPlayerMoney ( localPlayer )
	local Dinheiro_Banco = getElementData ( localPlayer, "Bank:Caixa" ) or 0
	local Procurado = getPlayerWantedLevel ( localPlayer )	
	local Vida = getElementHealth ( localPlayer )		
	
    local time = getRealTime()
    local hours = time.hour
    local minutes = time.minute
    local seconds = time.second

    if (hours >= 0 and hours < 10) then
        hours = "0"..time.hour
    end
    if (minutes >= 0 and minutes < 10) then
    	minutes = "0"..time.minute
    end
    if (seconds >= 0 and seconds < 10) then
    	seconds = "0"..time.second
    end

    dxDrawRectangle(x*1220, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO MONEY
    dxDrawRectangle(x*1076, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO HORA
    dxDrawRectangle(x*1220, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO BANCO
    dxDrawRectangle(x*932, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) -----FUNDO LEVEL	
    dxDrawRectangle(x*1076, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO PROCURADO	
    dxDrawRectangle(x*1220, y*62, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO VIDA	
    dxDrawText("$"..Dinheiro_Mao.."", x*1220, y*4, x*1360, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ----TEXTO MONEY
    dxDrawText("$"..Dinheiro_Banco.."", x*1220, y*33, x*1360, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false)--TEXTO BANCO
    dxDrawText("Nivel: "..Nivel.."", x*932, y*4, x*1072, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO LEVEL
    dxDrawText("Procurado: "..Procurado.."", x*1076, y*33, x*1216, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText("Vida: "..Vida.."", x*1220, y*62, x*1360, y*86, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText(""..hours..":"..minutes..":"..seconds.." Horas", x*1076, y*4, x*1216, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) --TEXTO HORAS	
    dxDrawLine(x*1220, y*58, x*1358, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA BANCO
    dxDrawLine(x*1220, y*29, x*1358, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA MONEY
    dxDrawLine(x*1076, y*29, x*1214, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA HORAS
    dxDrawLine(x*1076, y*58, x*1214, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA PROCURADO	
    dxDrawLine(x*932, y*29, x*1070, y*29, tocolor(255, 255, 255, 255), 1, false) --LINHA LEVEL	

 

Link to comment

Tentei isso, e funcionou. Muito obrigado ❤️

 

local Nivel = getElementData ( localPlayer, "Level" ) or 0
	local Dinheiro_Mao = getPlayerMoney ( localPlayer )
	local Dinheiro_Banco = getElementData ( localPlayer, "Bank:Caixa" ) or 0
	local Procurado = getPlayerWantedLevel ( localPlayer )	
	local Vida = math.floor(getElementHealth(localPlayer))		
	
    local time = getRealTime()
    local hours = time.hour
    local minutes = time.minute
    local seconds = time.second

    if (hours >= 0 and hours < 10) then
        hours = "0"..time.hour
    end
    if (minutes >= 0 and minutes < 10) then
    	minutes = "0"..time.minute
    end
    if (seconds >= 0 and seconds < 10) then
    	seconds = "0"..time.second
    end

    dxDrawRectangle(x*1220, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO MONEY
    dxDrawRectangle(x*1076, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO HORA
    dxDrawRectangle(x*1220, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO BANCO
    dxDrawRectangle(x*932, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) -----FUNDO LEVEL	
    dxDrawRectangle(x*1076, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO PROCURADO	
    dxDrawRectangle(x*1220, y*62, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO VIDA	
    dxDrawText("$"..Dinheiro_Mao.."", x*1220, y*4, x*1360, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ----TEXTO MONEY
    dxDrawText("$"..Dinheiro_Banco.."", x*1220, y*33, x*1360, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false)--TEXTO BANCO
    dxDrawText("Nivel: "..Nivel.."", x*932, y*4, x*1072, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO LEVEL
    dxDrawText("Procurado: "..Procurado.."", x*1076, y*33, x*1216, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText("Vida: "..math.floor(Vida/1), x*1220, y*62, x*1360, y*86, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText(""..hours..":"..minutes..":"..seconds.." Horas", x*1076, y*4, x*1216, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) --TEXTO HORAS	
    dxDrawLine(x*1220, y*58, x*1358, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA BANCO
    dxDrawLine(x*1220, y*29, x*1358, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA MONEY
    dxDrawLine(x*1076, y*29, x*1214, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA HORAS
    dxDrawLine(x*1076, y*58, x*1214, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA PROCURADO	
    dxDrawLine(x*932, y*29, x*1070, y*29, tocolor(255, 255, 255, 255), 1, false) --LINHA LEVEL	

 

Vamos supor que eu queira adicionar "." no valor do dinheiro e do banco a cada 3 casas

como faço?

Link to comment
10 minutes ago, Rangel said:

Tentei isso, e funcionou. Muito obrigado ❤️

 


local Nivel = getElementData ( localPlayer, "Level" ) or 0
	local Dinheiro_Mao = getPlayerMoney ( localPlayer )
	local Dinheiro_Banco = getElementData ( localPlayer, "Bank:Caixa" ) or 0
	local Procurado = getPlayerWantedLevel ( localPlayer )	
	local Vida = math.floor(getElementHealth(localPlayer))		
	
    local time = getRealTime()
    local hours = time.hour
    local minutes = time.minute
    local seconds = time.second

    if (hours >= 0 and hours < 10) then
        hours = "0"..time.hour
    end
    if (minutes >= 0 and minutes < 10) then
    	minutes = "0"..time.minute
    end
    if (seconds >= 0 and seconds < 10) then
    	seconds = "0"..time.second
    end

    dxDrawRectangle(x*1220, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO MONEY
    dxDrawRectangle(x*1076, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) ----FUNDO HORA
    dxDrawRectangle(x*1220, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO BANCO
    dxDrawRectangle(x*932, y*4, x*140, y*25, tocolor(0, 0, 0, 100), false) -----FUNDO LEVEL	
    dxDrawRectangle(x*1076, y*33, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO PROCURADO	
    dxDrawRectangle(x*1220, y*62, x*140, y*25, tocolor(0, 0, 0, 100), false) ---FUNDO VIDA	
    dxDrawText("$"..Dinheiro_Mao.."", x*1220, y*4, x*1360, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ----TEXTO MONEY
    dxDrawText("$"..Dinheiro_Banco.."", x*1220, y*33, x*1360, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false)--TEXTO BANCO
    dxDrawText("Nivel: "..Nivel.."", x*932, y*4, x*1072, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO LEVEL
    dxDrawText("Procurado: "..Procurado.."", x*1076, y*33, x*1216, y*58, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText("Vida: "..math.floor(Vida/1), x*1220, y*62, x*1360, y*86, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) ---TEXTO PROCURADO	
    dxDrawText(""..hours..":"..minutes..":"..seconds.." Horas", x*1076, y*4, x*1216, y*29, tocolor(255, 255, 255, 255), x*1.00, "default", "center", "center", false, false, false, false, false) --TEXTO HORAS	
    dxDrawLine(x*1220, y*58, x*1358, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA BANCO
    dxDrawLine(x*1220, y*29, x*1358, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA MONEY
    dxDrawLine(x*1076, y*29, x*1214, y*29, tocolor(255, 255, 255, 255), x*1, false) --LINHA HORAS
    dxDrawLine(x*1076, y*58, x*1214, y*58, tocolor(255, 255, 255, 255), x*1, false) --LINHA PROCURADO	
    dxDrawLine(x*932, y*29, x*1070, y*29, tocolor(255, 255, 255, 255), 1, false) --LINHA LEVEL	

 

Vamos supor que eu queira adicionar "." no valor do dinheiro e do banco a cada 3 casas

como faço?

Você pode usar esta função útil: convertNumber

  • Thanks 1
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...