Jump to content

Help DxText


MaurO^

Recommended Posts

Hello, I have my messaging system that at the moment of appearing this same begins to disappear with a fading of 5 seconds, my problem is that when this message is disappearing and another appears, both are with an alpha of 255, and disappear at the Same time, how do I solve this?

https://imgur.com/PQad4jb

https://imgur.com/tkrEe2j

https://imgur.com/HsVn6gg

Client.lua:

local sx, sy = guiGetScreenSize()

Messages = {}

function getProgress( addtick ) 
    local now = getTickCount() 
    local elapsedTime = now - tick 
    local duration = tick+addtick - tick 
    local progress = elapsedTime / duration 
    return progress 
end 

function createMessage(texto, r, g, b)
	if texto and type(texto) == "string" and string.len(texto) > 1 then
	    tick = getTickCount() 
		local tableMessages = {texto, r, g, b}
		table.insert(Messages, tableMessages)
		if(#Messages == 1) then
			addEventHandler("onClientRender", getRootElement(), dxText)
		end	
	end
end
addEvent("onCreateTextMessage", true)
addEventHandler("onCreateTextMessage", getRootElement(), createMessage)

function dxText()
	for i,v in ipairs(Messages) do
		if(i >= 6) then return end
		local alp = interpolateBetween(255, 0, 0, 0, 0, 0, getProgress(5000), "Linear")
		dxDrawOutlinedText(tocolor(0, 0, 0, alp), ""..v[1], sx*(3/1024), sy*(310/768) + i*25, sx*(478/1024), sy*(329/768), tocolor(v[2], v[3], v[4], alp), 1.00, "default-bold", "left", "top", false, false, false, false, false)
		if alp < 20 then
			table.remove(Messages, i)
		end	
	end
end	

function dxDrawOutlinedText(outlineColour, theText, posX, posY, sizeX, sizeY, fillColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos) 
    dxDrawText(theText, posX+1, posY+1, sizeX+1, sizeY+1, outlineColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos); 
    dxDrawText(theText, posX+1, posY-1, sizeX+1, sizeY-1, outlineColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos); 
    dxDrawText(theText, posX-1, posY+1, sizeX-1, sizeY+1, outlineColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos); 
    dxDrawText(theText, posX-1, posY-1, sizeX-1, sizeY-1, outlineColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos); 
    dxDrawText(theText, posX, posY, sizeX, sizeY, fillColour, textSize, theFont, horizontalAlign, verticalAlign, clippingBool, wordBreaking, postGUI, colourCoded, pixelPos); 
end 

 

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