Rangel Posted November 16, 2019 Share Posted November 16, 2019 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
beast99 Posted November 16, 2019 Share Posted November 16, 2019 Poste sempre seu código. 1 Link to comment
Rangel Posted November 16, 2019 Author Share Posted November 16, 2019 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
czarsight Posted November 16, 2019 Share Posted November 16, 2019 (edited) Utilize a seguinte função para arredondar o número. math.floor() Edited November 16, 2019 by czarsight 1 Link to comment
Rangel Posted November 16, 2019 Author Share Posted November 16, 2019 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
main Posted November 16, 2019 Share Posted November 16, 2019 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 1 Link to comment
Rangel Posted November 16, 2019 Author Share Posted November 16, 2019 dei uma olhada no topico mas n entendi como eu aplico, pode me ajudar? Link to comment
main Posted November 16, 2019 Share Posted November 16, 2019 Como é função útil, então necessita que você coloque isso dentro do seu código Em seguida, só utilizar a função: convertNumber(getElementData ( localPlayer, "Bank:Caixa" )) or 0 1 Link to comment
Rangel Posted November 16, 2019 Author Share Posted November 16, 2019 (edited) perfeito, funcionou tudo ok. mto obg tmj Edited November 16, 2019 by Rangel Link to comment
beast99 Posted November 16, 2019 Share Posted November 16, 2019 Não se esqueça de deixar um thanks, caso as respostas deles te ajudaram! 1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now