Jump to content

Aparecendo código de cor em vez de mudar a cor - DX MESSAGES


Recommended Posts

Bom, quando eu coloco o código para mudar a cor no dx message, ele não muda, ele só aparece o código
gostaria se tem como resolver isso, print do erro:
https://prnt.sc/u4hc8k

Script do DX MESSAGES: 

local displayWidth, displayHeight = guiGetScreenSize();

local notificationData = {};

local notificationFont = dxCreateFont('font/roboto.ttf', 12 * 2, false);
local iconsFont = dxCreateFont('font/icons.ttf', 12 * 2, false);

addEventHandler('onClientRender', root,
	function()
		for k, v in pairs(notificationData) do
			if (v.State == 'fadeIn') then
				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
				local alphaAnimation = interpolateBetween(0, 0, 0, 255, 0, 0, alphaProgress, 'Linear');
				
				if (alphaAnimation) then
					v.Alpha = alphaAnimation;
				else
					v.Alpha = 255;
				end
				
				if (alphaProgress > 1) then
					v.Tick = getTickCount();
					v.State = 'openTile';
				end
			elseif (v.State == 'fadeOut') then
				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
				local alphaAnimation = interpolateBetween(255, 0, 0, 0, 0, 0, alphaProgress, 'Linear');
				
				if (alphaAnimation) then
					v.Alpha = alphaAnimation;
				else
					v.Alpha = 0;
				end
				
				if (alphaProgress > 1) then
					notificationData = {};
				end
			elseif (v.State == 'openTile') then
				local tileProgress = (getTickCount() - v.Tick) / 350;
				local tilePosition = interpolateBetween(v.StartX, 0, 0, v.EndX, 0, 0, tileProgress, 'Linear');
				local tileWidth = interpolateBetween(0, 0, 0, v.Width, 0, 0, tileProgress, 'Linear');
				
				if (tilePosition and tileWidth) then
					v.CurrentX = tilePosition;
					v.CurrentWidth = tileWidth;
				else
					v.CurrentX = v.EndX;
					v.CurrentWidth = v.Width;
				end
				
				if (tileProgress > 1) then
					v.State = 'fixTile';
					
					setTimer(function()
						v.Tick = getTickCount();
						v.State = 'closeTile';
					end, string.len(v.Text) * 45 + 5000, 1);
				end
			elseif (v.State == 'closeTile') then
				local tileProgress = (getTickCount() - v.Tick) / 350;
				local tilePosition = interpolateBetween(v.EndX, 0, 0, v.StartX, 0, 0, tileProgress, 'Linear');
				local tileWidth = interpolateBetween(v.Width, 0, 0, 0, 0, 0, tileProgress, 'Linear');
				
				if (tilePosition and tileWidth) then
					v.CurrentX = tilePosition;
					v.CurrentWidth = tileWidth;
				else
					v.CurrentX = v.StartX;
					v.CurrentWidth = 0;
				end
				
				if (tileProgress > 1) then
					v.AlphaTick = getTickCount();
					v.State = 'fadeOut';
				end
			elseif (v.State == 'fixTile') then
				v.Alpha = 255;
				v.CurrentX = v.EndX;
				v.CurrentWidth = v.Width;
			end
			
			roundedRectangle(v.CurrentX, 20, 25 + v.CurrentWidth, 25, tocolor(0, 0, 0, 150 * v.Alpha / 255), _, true);
			dxDrawRectangle(v.CurrentX, 20, 25, 25, tocolor(0, 0, 0, 255 * v.Alpha / 255), true);
			
			if (v.Alpha == 255) then
				dxDrawText(v.Text, v.CurrentX + 25 + 10, 20, v.CurrentX + 25 + 10 + v.CurrentWidth - 20, 20 + 25, tocolor(255, 255, 255, 255), 0.40, notificationFont, 'center', 'center', false, false, true);
			end
			
			if (v.Type == 'error') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(215, 90, 90, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
			elseif (v.Type == 'warning') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(220, 180, 80, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
			elseif (v.Type == 'info') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(85, 180, 245, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
			elseif (v.Type == 'success') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(235, 154, 13, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true);
			end
		end
	end
)

addEvent('addNotification', true);
function addNotification(text, type)
	if (text and type) then
		if (notificationData ~= nil) then
			table.remove(notificationData, #notificationData);
		end
		
		table.insert(notificationData,
			{
				StartX = (displayWidth / 2) - (25 / 2),
				EndX = (displayWidth / 2) - ((dxGetTextWidth(text, 0.40, notificationFont) + 20 + 25) / 2),
				Text = text,
				Width = dxGetTextWidth(text, 0.40, notificationFont) + 20,
				Alpha = 0,
				State = 'fadeIn',
				Tick = 0,
				AlphaTick = getTickCount(),
				CurrentX = (displayWidth / 2) - (25 / 2),
				CurrentWidth = 0,
				Type = type or 'info'
			}
		);
		
		playSoundFrontEnd(11);
	end
end
addEventHandler('addNotification', root, addNotification);

function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
	if (x and y and w and h) then
		if (not borderColor) then
			borderColor = tocolor(0, 0, 0, 200);
		end
		
		if (not bgColor) then
			bgColor = borderColor;
		end
		
		
		dxDrawRectangle(x, y, w, h, bgColor, postGUI);
		
		
		dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); 
		dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); 
		dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); 
		dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); 
	end
end

 

Link to comment

dá uma olhada na página da Wiki dessa função aqui. Ou você coloca a cor no 6° argumento (color) ou você coloca true no 14° argumento, q é o coloredCode. Por padrão esse argumento é false, ou seja, o código hexadecimal é considerado texto, colocando true, o código que você escreve na sua string do 1° argumento é convertido em cor, não em texto.

Edited by Boechat
Link to comment
On 23/08/2020 at 14:41, Boechat said:

dá uma olhada na página da Wiki dessa função aqui. Ou você coloca a cor no 6° argumento (color) ou você coloca true no 14° argumento, q é o coloredCode. Por padrão esse argumento é false, ou seja, o código hexadecimal é considerado texto, colocando true, o código que você escreve na sua string do 1° argumento é convertido em cor, não em texto.

Aonde eu coloco true neste código para deixar em cor em vez de texto?

Link to comment
  • Moderators

O dx-text de sombra você precisa remover os códigos. O atributo colorCoded=true será nos dx-texts abaixo.

Tente isto:
 


local displayWidth, displayHeight = guiGetScreenSize();

local notificationData = {};

local notificationFont = dxCreateFont('font/roboto.ttf', 12 * 2, false);
local iconsFont = dxCreateFont('font/icons.ttf', 12 * 2, false);

addEventHandler('onClientRender', root,
	function()
		for k, v in pairs(notificationData) do
			if (v.State == 'fadeIn') then
				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
				local alphaAnimation = interpolateBetween(0, 0, 0, 255, 0, 0, alphaProgress, 'Linear');
				
				if (alphaAnimation) then
					v.Alpha = alphaAnimation;
				else
					v.Alpha = 255;
				end
				
				if (alphaProgress > 1) then
					v.Tick = getTickCount();
					v.State = 'openTile';
				end
			elseif (v.State == 'fadeOut') then
				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;
				local alphaAnimation = interpolateBetween(255, 0, 0, 0, 0, 0, alphaProgress, 'Linear');
				
				if (alphaAnimation) then
					v.Alpha = alphaAnimation;
				else
					v.Alpha = 0;
				end
				
				if (alphaProgress > 1) then
					notificationData = {};
				end
			elseif (v.State == 'openTile') then
				local tileProgress = (getTickCount() - v.Tick) / 350;
				local tilePosition = interpolateBetween(v.StartX, 0, 0, v.EndX, 0, 0, tileProgress, 'Linear');
				local tileWidth = interpolateBetween(0, 0, 0, v.Width, 0, 0, tileProgress, 'Linear');
				
				if (tilePosition and tileWidth) then
					v.CurrentX = tilePosition;
					v.CurrentWidth = tileWidth;
				else
					v.CurrentX = v.EndX;
					v.CurrentWidth = v.Width;
				end
				
				if (tileProgress > 1) then
					v.State = 'fixTile';
					
					setTimer(function()
						v.Tick = getTickCount();
						v.State = 'closeTile';
					end, string.len(v.Text) * 45 + 5000, 1);
				end
			elseif (v.State == 'closeTile') then
				local tileProgress = (getTickCount() - v.Tick) / 350;
				local tilePosition = interpolateBetween(v.EndX, 0, 0, v.StartX, 0, 0, tileProgress, 'Linear');
				local tileWidth = interpolateBetween(v.Width, 0, 0, 0, 0, 0, tileProgress, 'Linear');
				
				if (tilePosition and tileWidth) then
					v.CurrentX = tilePosition;
					v.CurrentWidth = tileWidth;
				else
					v.CurrentX = v.StartX;
					v.CurrentWidth = 0;
				end
				
				if (tileProgress > 1) then
					v.AlphaTick = getTickCount();
					v.State = 'fadeOut';
				end
			elseif (v.State == 'fixTile') then
				v.Alpha = 255;
				v.CurrentX = v.EndX;
				v.CurrentWidth = v.Width;
			end
			
			roundedRectangle(v.CurrentX, 20, 25 + v.CurrentWidth, 25, tocolor(0, 0, 0, 150 * v.Alpha / 255), _, true);
			dxDrawRectangle(v.CurrentX, 20, 25, 25, tocolor(0, 0, 0, 255 * v.Alpha / 255), true);
			
			if (v.Alpha == 255) then
				dxDrawText(removeHex(v.Text), v.CurrentX + 25 + 10, 20, v.CurrentX + 25 + 10 + v.CurrentWidth - 20, 20 + 25, tocolor(255, 255, 255, 255), 0.40, notificationFont, 'center', 'center', false, false, true);
			end
			
			if (v.Type == 'error') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(215, 90, 90, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);
			elseif (v.Type == 'warning') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(220, 180, 80, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);
			elseif (v.Type == 'info') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(85, 180, 245, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);
			elseif (v.Type == 'success') then
				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(235, 154, 13, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);
			end
		end
	end
)

addEvent('addNotification', true);
function addNotification(text, type)
	if (text and type) then
		if (notificationData ~= nil) then
			table.remove(notificationData, #notificationData);
		end
		
		table.insert(notificationData,
			{
				StartX = (displayWidth / 2) - (25 / 2),
				EndX = (displayWidth / 2) - ((dxGetTextWidth(text, 0.40, notificationFont) + 20 + 25) / 2),
				Text = text,
				Width = dxGetTextWidth(text, 0.40, notificationFont) + 20,
				Alpha = 0,
				State = 'fadeIn',
				Tick = 0,
				AlphaTick = getTickCount(),
				CurrentX = (displayWidth / 2) - (25 / 2),
				CurrentWidth = 0,
				Type = type or 'info'
			}
		);
		
		playSoundFrontEnd(11);
	end
end
addEventHandler('addNotification', root, addNotification);

function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
	if (x and y and w and h) then
		if (not borderColor) then
			borderColor = tocolor(0, 0, 0, 200);
		end
		
		if (not bgColor) then
			bgColor = borderColor;
		end
		
		
		dxDrawRectangle(x, y, w, h, bgColor, postGUI);
		
		
		dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); 
		dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); 
		dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); 
		dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); 
	end
end

function removeHex (s)
    if type (s) == "string" then
        while (s ~= s:gsub ("#%x%x%x%x%x%x", "")) do
            s = s:gsub ("#%x%x%x%x%x%x", "")
        end
    end
    return s or false
end

 

Link to comment
23 hours ago, DNL291 said:

O dx-text de sombra você precisa remover os códigos. O atributo colorCoded=true será nos dx-texts abaixo.

Tente isto:
 


local displayWidth, displayHeight = guiGetScreenSize();local notificationData = {};local notificationFont = dxCreateFont('font/roboto.ttf', 12 * 2, false);local iconsFont = dxCreateFont('font/icons.ttf', 12 * 2, false);addEventHandler('onClientRender', root,	function()		for k, v in pairs(notificationData) do			if (v.State == 'fadeIn') then				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;				local alphaAnimation = interpolateBetween(0, 0, 0, 255, 0, 0, alphaProgress, 'Linear');								if (alphaAnimation) then					v.Alpha = alphaAnimation;				else					v.Alpha = 255;				end								if (alphaProgress > 1) then					v.Tick = getTickCount();					v.State = 'openTile';				end			elseif (v.State == 'fadeOut') then				local alphaProgress = (getTickCount() - v.AlphaTick) / 650;				local alphaAnimation = interpolateBetween(255, 0, 0, 0, 0, 0, alphaProgress, 'Linear');								if (alphaAnimation) then					v.Alpha = alphaAnimation;				else					v.Alpha = 0;				end								if (alphaProgress > 1) then					notificationData = {};				end			elseif (v.State == 'openTile') then				local tileProgress = (getTickCount() - v.Tick) / 350;				local tilePosition = interpolateBetween(v.StartX, 0, 0, v.EndX, 0, 0, tileProgress, 'Linear');				local tileWidth = interpolateBetween(0, 0, 0, v.Width, 0, 0, tileProgress, 'Linear');								if (tilePosition and tileWidth) then					v.CurrentX = tilePosition;					v.CurrentWidth = tileWidth;				else					v.CurrentX = v.EndX;					v.CurrentWidth = v.Width;				end								if (tileProgress > 1) then					v.State = 'fixTile';										setTimer(function()						v.Tick = getTickCount();						v.State = 'closeTile';					end, string.len(v.Text) * 45 + 5000, 1);				end			elseif (v.State == 'closeTile') then				local tileProgress = (getTickCount() - v.Tick) / 350;				local tilePosition = interpolateBetween(v.EndX, 0, 0, v.StartX, 0, 0, tileProgress, 'Linear');				local tileWidth = interpolateBetween(v.Width, 0, 0, 0, 0, 0, tileProgress, 'Linear');								if (tilePosition and tileWidth) then					v.CurrentX = tilePosition;					v.CurrentWidth = tileWidth;				else					v.CurrentX = v.StartX;					v.CurrentWidth = 0;				end								if (tileProgress > 1) then					v.AlphaTick = getTickCount();					v.State = 'fadeOut';				end			elseif (v.State == 'fixTile') then				v.Alpha = 255;				v.CurrentX = v.EndX;				v.CurrentWidth = v.Width;			end						roundedRectangle(v.CurrentX, 20, 25 + v.CurrentWidth, 25, tocolor(0, 0, 0, 150 * v.Alpha / 255), _, true);			dxDrawRectangle(v.CurrentX, 20, 25, 25, tocolor(0, 0, 0, 255 * v.Alpha / 255), true);						if (v.Alpha == 255) then				dxDrawText(removeHex(v.Text), v.CurrentX + 25 + 10, 20, v.CurrentX + 25 + 10 + v.CurrentWidth - 20, 20 + 25, tocolor(255, 255, 255, 255), 0.40, notificationFont, 'center', 'center', false, false, true);			end						if (v.Type == 'error') then				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(215, 90, 90, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);			elseif (v.Type == 'warning') then				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(220, 180, 80, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);			elseif (v.Type == 'info') then				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(85, 180, 245, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);			elseif (v.Type == 'success') then				dxDrawText('', v.CurrentX + 5, 20, v.CurrentX + 5 + 25 - 10, 20 + 25, tocolor(235, 154, 13, v.Alpha), 0.50, iconsFont, 'center', 'center', false, false, true, true);			end		end	end)addEvent('addNotification', true);function addNotification(text, type)	if (text and type) then		if (notificationData ~= nil) then			table.remove(notificationData, #notificationData);		end				table.insert(notificationData,			{				StartX = (displayWidth / 2) - (25 / 2),				EndX = (displayWidth / 2) - ((dxGetTextWidth(text, 0.40, notificationFont) + 20 + 25) / 2),				Text = text,				Width = dxGetTextWidth(text, 0.40, notificationFont) + 20,				Alpha = 0,				State = 'fadeIn',				Tick = 0,				AlphaTick = getTickCount(),				CurrentX = (displayWidth / 2) - (25 / 2),				CurrentWidth = 0,				Type = type or 'info'			}		);				playSoundFrontEnd(11);	endendaddEventHandler('addNotification', root, addNotification);function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)	if (x and y and w and h) then		if (not borderColor) then			borderColor = tocolor(0, 0, 0, 200);		end				if (not bgColor) then			bgColor = borderColor;		end						dxDrawRectangle(x, y, w, h, bgColor, postGUI);						dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI); 		dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI); 		dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI); 		dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI); 	endendfunction removeHex (s)    if type (s) == "string" then        while (s ~= s:gsub ("#%x%x%x%x%x%x", "")) do            s = s:gsub ("#%x%x%x%x%x%x", "")        end    end    return s or falseend

 

Não deu certo, continuou com aquela sombra em baixo

Link to comment
  • Other Languages Moderators

Considerando que o texto possui esse retângulo escuro atrás. Eu acho bem inútil colocar sombra no texto, pois ele praticamente nem é visto.

Na minha opinião vc deveria simplesmente desativar esses outros textos de sombra e deixar só o texto principal.

Link to comment
On 27/08/2020 at 11:08, Lord Henry said:

Considerando que o texto possui esse retângulo escuro atrás. Eu acho bem inútil colocar sombra no texto, pois ele praticamente nem é visto.

Na minha opinião vc deveria simplesmente desativar esses outros textos de sombra e deixar só o texto principal.

Coloquei true em tudo, e continua dando isso, não consigo entender o pq disso...

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