Luccas

Colocar virgula no dinheiro

Recommended Posts

Olá, queira saber como faço para colocar virgulas no dinheiro. Tipo na hud o dinheiro tá 10000 queria colocar: 10,000

Código 

local money = getPlayerMoney(localPlayer)
if money > 99999999 then money = 99999999 end
	local cash = money
	local stcash = tostring(money)
if #stcash == 1 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
if #stcash == 2 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		

 

Share this post


Link to post
18 minutes ago, DNL291 said:

Eu fiz assim é deu erro

 

local money = getPlayerMoney(localPlayer)
if money > 99999999 then money = 99999999 end
    local convertedMoney = convertNumber(stcash) --- Já tentei trocar o stcash pra cash e também não funciono.
	local cash = money
	local stcash = tostring(money)
if #stcash == 1 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
if #stcash == 2 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end

----[convert]-----

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

 

Share this post


Link to post
17 minutos atrás, Jonas ^ disse:

Troque:


 

Por:


 

 

Agora deu erro d

Share this post


Link to post
local money = getPlayerMoney (localPlayer)
local convertedMoney = convertNumber(money)
if money > 99999999 then money = 99999999 end
local cash = convertedMoney
local stcash = tostring(convertedMoney)
if #stcash == 1 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
if #stcash == 2 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), 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

 

Share this post


Link to post
3 hours ago, Jonas^ said:

local money = getPlayerMoney (localPlayer)local convertedMoney = convertNumber(money)if money > 99999999 then money = 99999999 endlocal cash = convertedMoneylocal stcash = tostring(convertedMoney)if #stcash == 1 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) endif #stcash == 2 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	end	if #stcash == 3 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	 if #stcash == 4 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end		if #stcash == 5 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end if #stcash == 6 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	if #stcash == 7 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	if #stcash == 8 then	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), 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 formattedend

 

Opa, de erro no "convertNumber" Na linha 18
Erro: attempt to call global "convertNumber" (a nill value)

Share this post


Link to post
23 hours ago, Luccas said:

Opa, de erro no "convertNumber" Na linha 18
Erro: attempt to call global "convertNumber" (a nill value)

Se você testou da forma que está no post do Jonas, obviamente vai ter esse erro pois a convertNumber será chamada antes de ser definida como função.

Mostre seu código aqui.

Share this post


Link to post

Verdade, código atualizado:

addEventHandler ("onClientRender", root, function ()
	local money = getPlayerMoney (localPlayer)
	dxDrawBorderedText (1, "Seu Dinheiro:", 560, 344, 729, 376, tocolor(244, 131, 10, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false)
	dxDrawBorderedText (1, "$"..convertNumber(money), 729, 344, 898, 376, tocolor(255, 255, 255, 200), 2.00, "default-bold", "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

function dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
	for oX = (outline * -1), outline do 
		for oY = (outline * -1), outline do 
			dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(wr, wg, wb), scale, font, alignX, alignY, clip, wordBreak, postGUI) 
		end 
	end 
	dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end

Se não conseguir adaptar no seu código poste seu código atual que eu coloco, mas é só dar ctrl c + v no meu exemplo.

@Luccas

Share this post


Link to post
On 23/05/2019 at 22:16, Jonas^ said:

Verdade, código atualizado:


addEventHandler ("onClientRender", root, function ()	local money = getPlayerMoney (localPlayer)	dxDrawBorderedText (1, "Seu Dinheiro:", 560, 344, 729, 376, tocolor(244, 131, 10, 255), 2.00, "default-bold", "left", "top", false, false, false, false, false)	dxDrawBorderedText (1, "$"..convertNumber(money), 729, 344, 898, 376, tocolor(255, 255, 255, 200), 2.00, "default-bold", "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 formattedendfunction dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 	for oX = (outline * -1), outline do 		for oY = (outline * -1), outline do 			dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(wr, wg, wb), scale, font, alignX, alignY, clip, wordBreak, postGUI) 		end 	end 	dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) end

Se não conseguir adaptar no seu código poste seu código atual que eu coloco, mas é só dar ctrl c + v no meu exemplo.

@Luccas

local money = getPlayerMoney(localPlayer)
if money > 99999999 then money = 99999999 end
	local cash = money
	local stcash = tostring(money)
if #stcash == 1 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
if #stcash == 2 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end

----[convert]-----

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

 

Share this post


Link to post
local money = getPlayerMoney (localPlayer)
if money > 99999999 then money = 99999999 end
local cash = money
local stcash = tostring(money)
if #stcash == 1 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 2 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end

----[convert]-----

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

@Luccas

Share this post


Link to post

Testou o código que o Jonas postou? Digite /debugscript 3 para ver erros. 

Share this post


Link to post
17 hours ago, Jonas^ said:

local money = getPlayerMoney (localPlayer)if money > 99999999 then money = 99999999 endlocal cash = moneylocal stcash = tostring(money)if #stcash == 1 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end if #stcash == 2 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	end	if #stcash == 3 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	 if #stcash == 4 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end		if #stcash == 5 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end if #stcash == 6 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	if #stcash == 7 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end	if #stcash == 8 then	dxDrawText ("$"..convertNumber(cash), x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)	dxDrawImage (x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) end----[convert]-----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 formattedend

@Luccas

tá com erros 

No $"..convertNumber(cash)

17 hours ago, DNL291 said:

Testou o código que o Jonas postou? Digite /debugscript 3 para ver erros. 

Me ajuda?
 

Share this post


Link to post
Posted (edited)
2 hours ago, Luccas said:

Me ajuda?
 

É  o que estou tentando fazer. Mostra algum erro no seu debugmode?

Tente:

local x,y = guiGetScreenSize()
addEventHandler("onClientResourceStart", resourceRoot, function()

	addEventHandler ("onClientRender", root, drawPlayerMoney )
end)

function drawPlayerMoney()
	local money = getPlayerMoney (localPlayer)
	
	dxDrawBorderedText (1, "Seu Dinheiro:", 560, 344, 729, 376, tocolor(244, 131, 10, 255), 2.00, "default-bold", "left", "top")
	dxDrawBorderedText (1, "$"..convertNumber(money), 729, 344, 898, 376, tocolor(255, 255, 255, 200), 2.00, "default-bold", "left", "top")
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), 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

function dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
	for oX = (outline * -1), outline do
		for oY = (outline * -1), outline do
			dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
		end
	end
	dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)
end

 

Edited by DNL291

Share this post


Link to post
On 5/26/2019 at 5:19 PM, DNL291 said:

É  o que estou tentando fazer. Mostra algum erro no seu debugmode?

Tente:


local x,y = guiGetScreenSize()addEventHandler("onClientResourceStart", resourceRoot, function()	addEventHandler ("onClientRender", root, drawPlayerMoney )end)function drawPlayerMoney()	local money = getPlayerMoney (localPlayer)		dxDrawBorderedText (1, "Seu Dinheiro:", 560, 344, 729, 376, tocolor(244, 131, 10, 255), 2.00, "default-bold", "left", "top")	dxDrawBorderedText (1, "$"..convertNumber(money), 729, 344, 898, 376, tocolor(255, 255, 255, 200), 2.00, "default-bold", "left", "top")	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)endfunction 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 formattedendfunction dxDrawBorderedText (outline, text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)	for oX = (outline * -1), outline do		for oY = (outline * -1), outline do			dxDrawText (text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, 255), scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)		end	end	dxDrawText (text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI, colorCoded, subPixelPositioning, fRotation, fRotationCenterX, fRotationCenterY)end

 

Mais esse ai não tem como colocar na hud. Não tem como adptar ele no meu código não ?
 

Share this post


Link to post

Tem como, até dando Ctrl + C - Ctrl + V você só precisa saber aonde colocar.

Mostre como está seu código.

Share this post


Link to post
local money = getPlayerMoney(localPlayer)
if money > 99999999 then money = 99999999 end
	local cash = money
	local stcash = tostring(money)
if #stcash == 1 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
if #stcash == 2 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 	
end	
if #stcash == 3 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	 
if #stcash == 4 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end		
if #stcash == 5 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end 
if #stcash == 6 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 7 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end	
if #stcash == 8 then
	dxDrawText("  "..cash.."", x*1133, y*65, x*956, y*65, tocolor(255, 255, 255, 255), x*1.00, Font_1, "left", "top", false, false, false, false, false)
	dxDrawImage(x*1105, y*57, x*30, y*25, "Img/Carteira.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
end
----[convert]-----
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

@DNL291

Share this post


Link to post

Esse não é o código do seu Hud, tudo que tem aí é getPlayerMoney cheio de gambiarras, sem a função convertNumber (que eu mostrei no meu 1º post).

Desse jeito fica mais difícil ajudar... Se você testar meu último código verá que é o mesmo que esse mas funcionando. Assim você já quer script pronto.

Share this post


Link to post

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.