Hey there, I had a quick question about scheduling. Say I wanted to schedule an event to execute on a specific day at a specific time. Like January 1st 12:00 A.M. for instance. What would be the best way to going about doing this? One could simply check to see if you are near that date on the plugin enable, though that’s not very precise. I also thought about creating a scheduler that would just check periodically if it’s hit that time, but that seems like, depending on how often the scheduler checks, that could be a performance issue. Any thoughts?
Thanks!
The scheduler is efficient so unless you’re checking constantly I doubt it would make much difference.
What you can do is set a delay of the difference between time now and time wanted. Problem however is if the system clock changes then it may miss the exact time. For that you could just poll the time say every 30 seconds.
Agreed, is the scheduler persistent across server restarts? If it is, that’s awesome, and I would just use the first method you described, otherwise I suppose I could poll every X unit of time, it just seems like such a waste if the event is scheduled something like a month out for it to be constantly polling all the time. I could see some kind of hybrid system that checks to see if the event is close on the plugin enable, and then begins polling if it is.
If we’re talking more than a few days then yeah hybrid would probably be best.
Scheduled tasks can’t persist across restarts but you just need to set it off when the game first loads.