Jump to content

Timers


SkrillexX

Recommended Posts

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) 

Link to comment
  • Moderators

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

Link to comment
  • Moderators
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).

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