MaurO^ Posted January 1, 2019 Posted January 1, 2019 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
Moderators IIYAMA Posted January 1, 2019 Moderators Posted January 1, 2019 function getProgress( addtick, tick ) local tick = getTickCount() local tableMessages = {texto, r, g, b, tick} getProgress(5000, v[5]) By Attaching the tick data to the message. 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
MaurO^ Posted January 1, 2019 Author Posted January 1, 2019 1 hour ago, IIYAMA said: Adjuntando los datos de tick al mensaje. thank you, it worked 1
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