Skip to content
RustPluginGenerator

OnDeepSeaOpen

OnDeepSeaOpen is called when the server starts opening the deep sea event, right before its content is generated and the first opening timers are set. It fires once per opening cycle in OpenDeepSeaAsync.

Signature
void OnDeepSeaOpen(DeepSeaManager deepSeaManager)

Parameters

Hook parameters
ParameterTypeDescription
deepSeaManagerDeepSeaManagerThe DeepSeaManager entity that is about to open the deep sea event. Use it to read its position, network identity and flags, or to send network updates after you change state.

Return value

The return value is ignored. Returning null, returning a value, or doing nothing all leave the opening sequence unchanged; the method continues to log, set the Busy flag and generate content.

How it works

This hook fires inside DeepSeaManager.OpenDeepSeaAsync, at the very start of the opening sequence and before the manager is marked Busy, before SetTimeToWipe and SetTimeToNextOpening(0f) are applied, and before GenerateContentAsync runs. The single parameter is the DeepSeaManager performing the opening, so you can read its current state, trace which manager triggered the cycle, or react to the timing of the event.

Because the call happens before content generation, anything you change on the manager inside the hook runs ahead of the game's own setup. The hook is informational only: its return value is ignored, so you cannot cancel the opening from here. If you need to block or move a player's teleport to the deep sea, use the teleport-related hooks instead.

Declaring the parameter as DeepSeaManager is already the narrowest useful type; there is no broader base to widen or narrow further. Treat it as a rare, once-per-cycle signal rather than a per-tick event, so logging or broadcasting from it is acceptable.

Example plugin: Announce deep sea openings to the server

DeepSeaOpenAnnouncer.cs
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Deep Sea Open Announcer", "RustPluginGenerator", "1.0.0")]
    [Description("Announces deep sea openings in chat and keeps a small history for admins")]
    public class DeepSeaOpenAnnouncer : RustPlugin
    {
        private const string PermAdmin = "deepseaopenannouncer.admin";

        private PluginConfig config;
        private readonly List<string> openings = new List<string>();

        private class PluginConfig
        {
            [JsonProperty("Announce in chat")]
            public bool AnnounceInChat { get; set; } = true;

            [JsonProperty("Keep history entries")]
            public int HistoryLimit { get; set; } = 10;
        }

        private class AnnounceState
        {
            [JsonProperty("Last openings (UTC)")]
            public List<string> Openings { get; set; } = new List<string>();
        }

        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>
            {
                ["Announce"] = "The deep sea is opening. Head to the docks and sail out.",
                ["LastOpening"] = "Last deep sea opening: {0}",
                ["NoHistory"] = "No deep sea opening recorded yet."
            }, this);
        }

        private string Msg(string key, string userId = null, params object[] args)
        {
            return string.Format(lang.GetMessage(key, this, userId), args);
        }

        private void Init()
        {
            permission.RegisterPermission(PermAdmin, this);
            LoadHistory();
        }

        private void LoadHistory()
        {
            var state = Interface.Oxide.DataFileSystem.ReadObject<AnnounceState>(Name);
            if (state?.Openings != null)
            {
                openings.Clear();
                openings.AddRange(state.Openings);
            }
        }

        private void SaveHistory()
        {
            Interface.Oxide.DataFileSystem.WriteObject(Name, new AnnounceState { Openings = new List<string>(openings) });
        }

        private void OnDeepSeaOpen(DeepSeaManager deepSeaManager)
        {
            if (deepSeaManager == null || deepSeaManager.IsDestroyed) return;

            string stamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " UTC";
            openings.Add(stamp);
            while (openings.Count > Math.Max(1, config.HistoryLimit))
                openings.RemoveAt(0);
            SaveHistory();

            if (config.AnnounceInChat)
                Server.Broadcast(Msg("Announce"));
        }

        [ConsoleCommand("deepsea.last")]
        private void CmdLast(ConsoleSystem.Arg arg)
        {
            var player = arg.Player();
            if (player != null && !player.IsAdmin && !permission.UserHasPermission(player.UserIDString, PermAdmin)) return;

            string reply = openings.Count == 0
                ? Msg("NoHistory")
                : Msg("LastOpening", player?.UserIDString, openings[openings.Count - 1]);

            if (player != null) SendReply(player, reply);
            else if (arg != null) arg.ReplyWith(reply);
        }
    }
}

The plugin reacts to OnDeepSeaOpen by broadcasting a chat message that the deep sea is opening, and records the event time so admins can review a small history. It tracks the most recent opening in memory and exposes a console command to print the last timestamp. Everything player-facing goes through the language file, and the hook only fires once per opening cycle, so no timers or throttling are needed. The manager reference is used to confirm the entity is still valid before reading its position for the message.

Common use cases

  • Notify the server

    Broadcast a chat or console message when the deep sea opens so players know to head to the docks.

  • Event scheduling

    Start a secondary timer, such as a PvP window or reward multiplier, that lasts for the duration of the deep sea event.

  • Audit logging

    Record opening times to a data file so admins can correlate crashes or player reports with event cycles.

Pitfalls

  • Cannot cancel from here

    The return value is ignored, so this hook cannot stop the opening. Use the teleport and sail hooks if you need to block player entry.

  • Runs before content exists

    Content is generated in GenerateContentAsync after the hook fires, so do not expect loot or locations to already be set when you read the manager.

  • DeepSeaManager reference can be recreated

    Treat the manager as potentially destroyed if you store it for later use; always check IsDestroyed before reading it in a delayed callback.

Build a plugin with OnDeepSeaOpen

Describe what should happen and get a compiled plugin that uses this hook.

Prompt: Notify the server using the OnDeepSeaOpen hook, with a config file and a permission
Generate this plugin

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 OnDeepSeaOpen

Generate