OnHuntEventEnd
OnHuntEventEnd is called from EggHuntEvent.Update when the egg hunt's active duration has elapsed and the cooldown invoke has not yet been scheduled.
object OnHuntEventEnd(EggHuntEvent eggHuntEvent)Parameters
| Parameter | Type | Description |
|---|---|---|
eggHuntEvent | EggHuntEvent | The EggHuntEvent entity instance whose Update is running. Read its position, flags and network ID, or call CleanupEggs and PrintWinnersAndAward yourself if you want to replace the default end routine. |
Return value
Returning null lets the game proceed with its normal end sequence: flag set, eggs cleaned, winners awarded, cooldown started. Returning any non-null value stops that block before it runs, so the hunt does not clean up eggs, does not award prizes, and does not start the cooldown this tick.
How it works
The hook fires inside EggHuntEvent.Update on the server tick after timeAlive - warmupTime exceeds the event's durationSeconds, provided the event is not already in its 10-second cooldown. It runs just before the vanilla end sequence: setting Flags.Reserved2, calling CleanupEggs(), calling PrintWinnersAndAward(), and scheduling the cooldown. Use eggHuntEvent to identify the running event (its net.ID.Value, transform position, or flags) if you run more than one hunt or want to key your own state off the entity. Since the only parameter is EggHuntEvent, declaring a different type would cause Oxide to skip the call, so keep the declared type as-is. The hook fires once per event end cycle, not per tick, because the pending cooldown invoke blocks re-entry. Use it for broadcasts, score summaries, or to inspect the event before the game clears eggs and awards winners.
Example plugin: Log egg hunt winners and broadcast the end
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Hunt Event End Announcer", "RustPluginGenerator", "1.0.0")]
[Description("Announces and logs the end of egg hunt events.")]
public class HuntEventEndAnnouncer : RustPlugin
{
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Broadcast message")]
public string BroadcastMessage = "The egg hunt has ended. Winners are being awarded!";
[JsonProperty("Log to console")]
public bool LogToConsole = true;
}
protected override void LoadDefaultConfig() => config = new PluginConfig();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<PluginConfig>();
if (config == null) throw new Exception();
}
catch
{
PrintWarning("Configuration file is invalid, using defaults");
LoadDefaultConfig();
}
SaveConfig();
}
protected override void SaveConfig() => Config.WriteObject(config);
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["HuntEnded"] = "The egg hunt has ended. Winners are being awarded!",
["LogLine"] = "Egg hunt event {0} ended at {1}."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
{
return string.Format(lang.GetMessage(key, this, userId), args);
}
private object OnHuntEventEnd(EggHuntEvent eggHuntEvent)
{
if (eggHuntEvent == null) return null;
if (config.LogToConsole)
{
var pos = eggHuntEvent.transform != null ? eggHuntEvent.transform.position : Vector3.zero;
PrintWarning(Msg("LogLine", null, eggHuntEvent.net.ID.Value, pos.ToString("F0")));
}
var message = string.IsNullOrEmpty(config.BroadcastMessage) ? Msg("HuntEnded") : config.BroadcastMessage;
Server.Broadcast(message);
return null;
}
}
}The plugin listens for the end of any egg hunt, broadcasts a configurable chat line to every connected player, and writes a short summary to the server console. It records the event entity's network ID and world position so administrators can correlate the announcement with the actual event instance on their map. Returning null keeps the vanilla cleanup and prize award intact, which is the usual behavior admins expect. All player-facing text goes through the language file so it can be localized or edited without recompiling.
Common use cases
Broadcast hunt end to players
Send a chat or server-wide announcement when the egg hunt finishes so players know the round is over and winners are being awarded.
Audit event activity
Write the event's network ID and position to the console log so admins can track how many hunts ran and where they were placed.
Chain custom rewards
Grant extra items or currency to the event's top scorers by reading state you tracked during the hunt, then let the vanilla award routine run normally.
Pitfalls
Non-null return blocks the event end
Returning anything other than null prevents egg cleanup, prize awarding and cooldown scheduling. Only return a value when you are deliberately taking over the end sequence with your own logic.
Not a per-player hook
The hook fires once for the whole event, not once per participant. If you need per-player results, track pickups elsewhere (OnEventCollectablePickup) and use this hook only as the close-out signal.
Timing follows the server tick
It runs from Update, so the moment it fires depends on the current tick rate and the event's own durationSeconds field. Do not assume a fixed wall-clock end time.
Build a plugin with OnHuntEventEnd
Describe what should happen and get a compiled plugin that uses this hook.
Edit the prompt on the next screen. 2 free plugins a month, no card.
Last updated Oct 26, 2026. Found a mistake? Email support@rustplugingenerator.com.
Build a plugin with OnHuntEventEnd
Generate