Every hour and half a hour - 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: Every hour and half a hour (
/showthread.php?tid=656548)
Re: Every hour and half a hour -
Florin48 - 27.07.2018
Quote:
Originally Posted by GospodinX
But where to use gettime? I don't understand.
|
try at OnPlayerUpdate(playerid)
Re: Every hour and half a hour -
GospodinX - 27.07.2018
Quote:
Originally Posted by Florin48
try at OnPlayerUpdate(playerid)
|
haha
Re: Every hour and half a hour -
BlackBank - 27.07.2018
Quote:
Originally Posted by GospodinX
But where to use gettime? I don't understand.
|
Check my code, that's exactly what you want. You can even put the timer to 10 seconds or 1 min, it's up to you how acurate you want it.
Re: Every hour and half a hour -
AmigaBlizzard - 27.07.2018
Run a 1 second timer to be accurate, then check if "minute" is 0 or 30 and a flag is 0.
If so, execute your stuff and set the flag to 1.
To reset the flag, add a second if-statement to check if "minute" is 1 or 31, if so, set the flag back to 0.
This flag blocks your stuff to be executed 60 times per minute.
And your code gets executed within one second after the time reaches "minute" 0 or 30.
Florin48 provided an example of such a flag.
To retrieve the current hour, minute and second using gettime, check this:
https://sampwiki.blast.hk/wiki/Gettime
And doing it with just checking for "minute" 0 or 30 and the flag, you don't even need to check for the hour, unless you want to skip certain hours.