Skip to main content

Scheduled Server Events

At server load, you can schedule anything to happen at later time. Within callback handler you can also call callback.reschedule() to repeat this event after initial timer or callback.reschedule(newTime) to change it.

Whatever you pass as 2nd argument will be returned in callback as data.

The example script restarts server after 2 hours but notifies players 5 minutes before that.

onEvent('server.load', function (event) {
  event.server.schedule(115 * MINUTE, event.server, function (callback) {'Server restarting in 5 minutes!')
  event.server.schedule(120 * MINUTE, event.server, function (callback) {'/stop')