Callback being called on hour starts - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Callback being called on hour starts (
/showthread.php?tid=507697)
Callback being called on hour starts -
Baltazar - 18.04.2014
Is there a callback that's being called on hour starts (at 0:00, at 1:00, ... 16:00 etc.)?
Re: Callback being called on hour starts -
Bingo - 18.04.2014
No I think,
But Timers are used to count ONtime of player which will be under OnPlayerConnect.
Re: Callback being called on hour starts -
Baltazar - 18.04.2014
Quote:
Originally Posted by Bingo
No I think,
But Timers are used to count ONtime of player which will be under OnPlayerConnect.
|
This can't depend on players online. And yes, I can create a timer, that checks constantly if new hour has started, but that seems to be such a waste... need a callback.
AW: Callback being called on hour starts -
Nero_3D - 18.04.2014
Why do you need an timer that checks if an hour passed?
Just create a timer who gets called each hour
pawn Код:
SetTimer("EachHour", 1000 * 60 * 60, true);
To sycn it with the clock you just calculate the remaining seconds and call than the timer
pawn Код:
// OnGameModeInit
HourTimer();
// global
forward HourTimer();
public HourTimer() {
// code
new
hour,
minute,
second
;
gettime(hour, minute, second);
SetTimer("HourTimer", (3599 - minute * 60 - seconds) * 1000, false);
}