Skip to content

Using C# Events (P1)

ced777ric edited this page Feb 10, 2025 · 1 revision

Subscribing to events

All your event subscriptions should be done when your plugin is enabled.

public override void Enable()
{
    ServerEvents.WaveRespawned += OnWaveRespawned
}

Unsubscribing to events

At the same time, all your event unsubscriptions should be done when your plugin is being disabled.

Unsubscriptions are useful to avoid memory leaks and will ensure that once your plugin is disabled the event won't be called anymore.

public override void Disable()
{
    ServerEvents.WaveRespawned -= OnWaveRespawned;
}

Clone this wiki locally