Jump to content

interpolateBetween need help


Xwad

Recommended Posts

Posted

The text appears succesfully but i cant make it disappear:/ Pls help!

[lua]

function fadeDX()
startTick = getTickCount()
addEventHandler("onClientRender",root,text)
end 

function text() 
    local currentTick = getTickCount()
    local progress = (currentTick-startTick)/duration
    local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad")
    
    dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3)
    
    setTimer ( function()
    startTick = nil,nil
    removeEventHandler("onClientRender",root,text)

    local currentTick = getTickCount()
    local progress = (currentTick+startTick)/duration
    local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad")
    
    dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3)
    end, 8000, 1 )
end

[/lua]

Posted

You can use a timer to remove the event handler 

local duration = 5000
local x,y = guiGetScreenSize()

function fadeDX()
    startTick = getTickCount()
    addEventHandler("onClientRender",root,text)
    setTimer (function()
        removeEventHandler("onClientRender",root,text)
    end,8000,1)
end 


function text() 
    local currentTick = getTickCount()
    local progress = (currentTick-startTick)/duration
    local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad")
    dxDrawText ("D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3)
end

or check if the alpha == 255 then remove the event handler like this

local duration = 5000
local x,y = guiGetScreenSize()

function fadeDX()
    startTick = getTickCount()
    addEventHandler("onClientRender",root,text)
end 


function text() 
    local currentTick = getTickCount()
    local progress = (currentTick-startTick)/duration
    local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad")
    dxDrawText ( "D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3)
    if tonumber(alpha) == 255 then 
        removeEventHandler("onClientRender",root,text)
    end 
end

 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted (edited)

No, my problem is not with the simple disappear. My problem is that i cant make it disappear with the alpha effect.

like this, but its not workin

 

local x,y = guiGetScreenSize()

local duration = 1500

function fadeDX()
    startTick = getTickCount()
    addEventHandler("onClientRender",root,text)
    setTimer (function()
        removeEventHandler("onClientRender",root,text)
        addEventHandler("onClientRender",root,text2)
    end,3000,1)
end 


function text() 
    local currentTick = getTickCount()
    local progress = (currentTick-startTick)/duration
    local alpha = interpolateBetween(0,0,0,255,0,0,progress,"InOutQuad")
    dxDrawText ("D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha), 3)
end

function text2() 
    alpha = 255
    dxDrawText ("D-Day", x/2.05, y/3, x, y, tocolor(255, 255, 255, alpha-5), 3)
end

Edited by Xwad

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