Jump to content

Each full hour execute a function


Recommended Posts

Hey,

I want to execute a function when a new hour begins (don't know how to describe it :/)

So for example:

It is 3pm: Execute function abc

It is 4pm: Execute function abc

...

I tried it with a timer, but I don't want to check whether it is a full hour or not each minute.

Does anyone know how to check if it is a full hour, without checking each second or minute?

Link to comment
getTime 
setTimer 

When resource starts, check the time and make a timer like, if the clock is 35 minutes past 1pm, it will count 25 minutes until it makes something, after it executes something, it starts an another timer with a 60 minute timer.

Link to comment
Guest Guest4401
setTimer( 
    function() 
        local hour, minute = getTime() 
        if minute == 0 then -- if minute is 0, it means that the next hour is started 
            abc() 
        end 
    end, 1000, 0 -- see every second if an hour is passed 
) 
  
function abc() 
    outputChatBox"Hello" 
end 

Link to comment
  
time = getRealTime() 
setTimer(function() 
    setTimer(abc, 60*60*1000, 0) 
end, (60-time.minute)*60*1000, 1) 
  
  
--note the 'abc' name is the name of the ultimate function that you wish to call. 

also note that if you're going to take someone else's code.. I see most people here are using getTime() but you should know that that function returns the current IN-GAME hour and minute. If you want the real time then use getRealTime()

and the in-game time is different so that hours are minutes and minutes are seconds

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