Jump to content

Alternative for setTimer


Overkillz

Recommended Posts

Hey guys, since I started to doing my scripts, to stop the event after being showed ...etc or something similar I use setTimer.

However, this function sometimes causes me some problems, I would like to know if I can use another one.

like:

  
tick = getTickCount() 
if tick == 2000 then <-- This should be the seconds 
statusToChangeSomething = true 
end 

I dont know if u got me, well, for example, I use interpolateBetween to do a fade effect on alpha, well,

if alpha == 0 then 
removeEventHandler("Namefunction" ...) 
end 

There are ways to do that.

Thanks for your time.

Regards.

Link to comment
Are you talking about something like this?
if getTickCount() - startTime > 2000 then 

Also, you should use <= 0 for that alpha thing as it is unlikely to reach exactly 0, depending on the value you are using to decrease it.

Thanks dude, then this should works fine ?

function simpleInter() 
    local tick = getTickCount() - dxUInterface.pretratick 
    local progress = math.min(tick/5000) 
    if dxUInterface.started then 
        dxUInterface.pretraalpha = interpolateBetween(0,0,0,255,0,0,progress2,"Linear") 
    end 
    dxDrawRectangle(0,0,sX,sY,tocolor(0,0,0,dxUInterface.pretraalpha/1.3)) 
    if getTickCount() - dxUInterface.pretratick > 2000 then 
    removeEventHandler("onClientRender",getRootElement(),simpleInter) 
    end 
end 
addEventHandler("onClientRender",getRootElement(),simpleInter) 

variables are already set.

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