Jump to content

Timers


SkrillexX

Recommended Posts

Posted

How to check if a Timer i've set earlier is over ( the time is over ) or not , Like for example , i've set a Timer with 5 minutes , how to check if those 5 minutes are over or not

Posted

Let's say that i've precised earlier this :

setTimer ( randomFunction ,6000000 ,0 ) 

600000 = 5 minutes

How to check if they're over using

getTimerDetails 

Posted

Check this example from wiki,It might be usefull for you

theTimer = setTimer(function() end, 1000, 10) -- A timer that does nothing. 
  
function timerDetails() 
    remaining, executesRemaining, totalExecutes = getTimerDetails(theTimer) -- Get the timers details 
    if (remaining and executesRemaining and totalExecutes) then 
        outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Total executes: "..totalExecutes) 
    else 
        outputChatBox("Timer no longer exists") 
    end 
end 
addCommandHandler("timerdetails", timerDetails) 

Posted

If you want to know the time left to execute the function, use:

local remaining = getTimerDetails(theTimer) 

But if you want to know if the time stopped running, just use the attached function with setTimer (when it's called, means that the time stopped running).

Posted

Could you tell me a bit more on where you are planning to use this, there might be a chance that it could be done without timers using tick count which would improve effectiveness.

  • Moderators
Posted
Let's say that i've precised earlier this :
setTimer ( randomFunction ,6000000 ,0 ) 

600000 = 5 minutes

How to check if they're over using

getTimerDetails 

You need to use a variable to store it like the wiki did.

And then use that variable as 1srgument of getTimerDetails.

Don't use infinite timer if you want to know if the 5 mins are passed (oh and 5 mins = 5 * 60 secs = 300 * 1000 ms = 300000 ms)

in the case of a non infinite timer, getTimerDetails will return false when the timer is done (passed 5 mins).

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