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.

events.listen('server.load', function (event) {
  event.server.schedule(115 * MINUTE, event.server, function (callback) {
    callback.data.tell('Server restarting in 5 minutes!')
  })
  
  event.server.schedule(120 * MINUTE, event.server, function (callback) {
    callback.data.runCommand('/stop')
  })
})

Revision #3
Created Fri, Aug 7, 2020 10:08 AM by LatvianModder
Updated Thu, Sep 3, 2020 1:04 PM by LatvianModder