OnDeepSeaClosed
OnDeepSeaClosed is called after the DeepSeaManager finishes its close routine and the deep sea is toggled off. Use it to react to the deep sea session ending, such as announcing it or cleaning up per-session state.
void OnDeepSeaClosed(DeepSeaManager deepSeaManager)Parameters
| Parameter | Type | Description |
|---|---|---|
deepSeaManager | DeepSeaManager | The DeepSeaManager entity that just finished closing the deep sea session. It is a BaseNetworkable (usable for net.ID.Value, transform.position, ShortPrefabName) and it is the same instance that was passed to the open hook earlier. |
Return value
The return value is ignored. OnDeepSeaClosed is injected with a plain continue behavior, so returning null or any value does not change the original close path.
How it works
This hook fires at the end of DeepSeaManager.CloseDeepSeaAsync, right after the game kills the manager when DeepSea.enabled is false and after the Azure analytics toggle event. It is the closing counterpart to the open hook and runs once per close, not per frame.
The single argument is the manager entity. Since it is a BaseNetworkable, you can read net.ID.Value, transform.position and ShortPrefabName, which is enough to identify the session. The manager may already be marked for destruction by the time you receive it, so treat it as read-only data.
Declaring the parameter as DeepSeaManager is the only matching option; narrowing it to a base type like BaseEntity still works because Oxide dispatches on the argument's runtime type, but there is no benefit. Do not cache the manager beyond a short timer, and avoid heavy work here since the close path runs on the server thread.
This is a naval event: it pairs with the open hooks to bracket a deep sea session.
Example plugin: Announce deep sea closures and log session end
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Deep Sea Close Announcer", "RustPluginGenerator", "1.0.0")]
[Description("Broadcasts a chat message and logs when a deep sea session closes")]
public class DeepSeaCloseAnnouncer : RustPlugin
{
private PluginConfig config;
private class PluginConfig
{
[JsonProperty("Announce to chat")]
public bool AnnounceToChat = true;
[JsonProperty("Write session log to data file")]
public bool WriteLog = true;
}
private sealed class CloseRecord
{
[JsonProperty("Manager ID")]
public ulong ManagerId;
[JsonProperty("Position")]
public string Position;
[JsonProperty("Closed at (UTC)")]
public string ClosedAt;
}
private const string LogFileName = "DeepSeaCloseLog";
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>
{
["Closed"] = "The deep sea session has closed.",
["ClosedAt"] = "Deep sea closed near {0}."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
=> string.Format(lang.GetMessage(key, this, userId), args);
private void OnDeepSeaClosed(DeepSeaManager deepSeaManager)
{
if (deepSeaManager == null) return;
ulong managerId = 0;
Vector3 position = Vector3.zero;
if (deepSeaManager.net != null)
{
managerId = deepSeaManager.net.ID.Value;
position = deepSeaManager.transform.position;
}
if (config.WriteLog)
{
WriteRecord(new CloseRecord
{
ManagerId = managerId,
Position = position.ToString(),
ClosedAt = DateTime.UtcNow.ToString("u")
});
}
if (!config.AnnounceToChat) return;
string message = position == Vector3.zero
? Msg("Closed")
: Msg("ClosedAt", null, position.ToString("0"));
Server.Broadcast(message);
}
private void WriteRecord(CloseRecord record)
{
var log = Interface.Oxide.DataFileSystem.ReadObject<List<CloseRecord>>(LogFileName);
if (log == null) log = new List<CloseRecord>();
log.Add(record);
while (log.Count > 200) log.RemoveAt(0);
Interface.Oxide.DataFileSystem.WriteObject(LogFileName, log);
}
}
}The plugin reacts to the end of a deep sea session. When OnDeepSeaClosed fires it records the manager's network ID and position, then broadcasts a localized chat message to everyone online. A config flag toggles the broadcast so admins can keep it silent. The message text lives in the language file, so servers can translate it without recompiling. The hook null-checks the manager and its net before reading anything. No timers or UI are needed; the plugin only reads and reports, so unload is trivial.
Common use cases
Server-wide notice
Broadcast a chat line when a deep sea session ends so players know the area is closing and can plan travel.
Session bookkeeping
Record the close time and manager ID in a small data file so admins can audit how often the deep sea is opened.
Clean up tracked state
If you track players or loot related to the deep sea from the open hook, use the close hook to clear that state instead of relying on timers.
Pitfalls
Manager may be destroyed soon
The manager is killed on the close path, so do not hold the instance in a field or use it after a delay; copy the ID and position immediately.
Not a per-player event
The hook fires once for the session, with no player attached. If you need per-player reactions, iterate active players yourself and filter by area.
Runs on the server thread
Keep the handler short; heavy work such as spawning many entities or scanning all entities will stall the close routine.
Build a plugin with OnDeepSeaClosed
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 OnDeepSeaClosed
Generate