BriGhtx3 Posted June 8, 2012 Share Posted June 8, 2012 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
myonlake Posted June 8, 2012 Share Posted June 8, 2012 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
BriGhtx3 Posted June 8, 2012 Author Share Posted June 8, 2012 How exactly? So for example I execute getTime to get the current time. If it is 3.25 pm then I set the timer for 35 minutes. But how do I set the timer again for 60 minutest? Link to comment
Guest Guest4401 Posted June 8, 2012 Share Posted June 8, 2012 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
BinSlayer1 Posted June 8, 2012 Share Posted June 8, 2012 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
BriGhtx3 Posted June 8, 2012 Author Share Posted June 8, 2012 Thanks I already got it with myonlake solution^^ @BinSlayer1 of course I use getRealTime because I need it for a lottery Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now