1 minute to read
Created by
Calytic
Updated by
Wulf
Timers
Details on how to use timers.
This guide is for uMod, not Oxide.
Join our discord for the latest updates and the latest news! Join discord
A timer invokes a callback or anonymous function after a set interval.
Once
Execute once after the specified delay interval (in seconds).
timer.Once(1f, () =>
{
Logger.Info("Hello world!");
});
Every
Execute forever or until the timer is manually destroyed (or the plugin is unloaded).
timer.Every(3f, () =>
{
Logger.Info("Hello world!");
});
Repeat
Execute repeatedly until the timer is executed the specified number of times.
timer.Repeat(5f, 0, () =>
{
Logger.Info("Hello world!");
});
RepeatUntil
Execute repeatedly until the specified condition is satisfied.
int count = 0;
timer.RepeatUntil(5f, () => count == 5, () =>
{
count++;
Logger.Info($"Hello {count}");
});
NextFrame
Execute immediately in the next frame.
timer.NextFrame(() =>
{
Logger.Info("Hello world!");
});
Destroy timers
When a timer is no longer operating, it is marked as destroyed. Timers may also be destroyed manually if stored in a variable.
Timer myTimer = timer.Every(3f, () =>
{
Logger.Info("Hello world!");
});
myTimer.Destroy();
if (myTimer.Destroyed)
{
Logger.Info("Timer destroyed!");
}