Scheduler
Run delayed and repeating plugin tasks scoped to plugin lifetime.
In this section
Related section pages:
Plugin-scoped Tasks
Use ctx.Scheduler() for lightweight delayed and repeating plugin tasks. Tasks created from the plugin context are scoped to the plugin and are canceled automatically when the plugin is stopped or unloaded.
Delayed Task
Delayed tasks are useful for short follow-up actions after an event, command, or form response.
scheduler-later.go
ctx.Scheduler().Later(2*time.Second, func(task context.Context) { playerHandle, ok := ctx.Gameplay().Players().Resolve("Steve") if !ok || task.Err() != nil { return } _ = playerHandle.SendMessage("Ready")})Repeating Task
Repeating tasks return a cancel function. You can stop them manually before plugin unload, or let the plugin scope cancel them automatically.
scheduler-repeat.go
cancel := ctx.Scheduler().Repeat(30*time.Second, func(task context.Context) { for _, playerHandle := range ctx.Gameplay().Players().All() { _ = playerHandle.SendTip("Arena is live") }})// Optional manual stop before plugin unload.cancel()