Skip to content
RustPluginGenerator

OnFogOfWarStale

OnFogOfWarStale is called on the server after a player's explored-map (fog of war) data has been reset to its stale/empty state.

Signature
void OnFogOfWarStale(BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer whose fog-of-war image lists were just reset. It is the owner of the BasePlayer instance the server method runs on, so it is never null when the hook fires.

Return value

The original method returns void and the hook is called with its return value ignored, so returning null or any value has no effect on the reset. The fog lists are already cleared and refilled before the hook runs.

How it works

Oxide fires this hook from BasePlayer.OnFogOfWarStale, immediately after the method clears both the main-island and deep-sea fog image lists and repopulates them with their 16 default entries. Because the call sits at the end of the method, the player's fog data has already been reset by the time your plugin sees the hook. The single parameter is the BasePlayer involved, giving you access to UserIDString, displayName, connection state and position. There is only one signature, so there is nothing to narrow by declaring a more specific type. In practice this method runs when the server decides a player's stored fog image is no longer valid, so treat the hook as a notification that the client's map reveal state is being rebuilt, not as an interception point: you cannot block or alter the reset. It fires per player and can run while the player is connected, so keep the handler cheap and avoid chat spam in it.

Example plugin: Tell players their map reveal was reset

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

namespace Oxide.Plugins
{
    [Info("Fog Reset Notice", "RustPluginGenerator", "1.0.0")]
    [Description("Notifies players when their fog-of-war map data is rebuilt")]
    public class FogResetNotice : RustPlugin
    {
        private class PluginConfig
        {
            [JsonProperty("Send chat notice")]
            public bool SendNotice { get; set; } = true;

            [JsonProperty("Minimum seconds between notices per player")]
            public float CooldownSeconds { get; set; } = 300f;
        }

        private PluginConfig config;
        private readonly Dictionary<string, float> lastNotice = new Dictionary<string, float>();

        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>
            {
                ["Notice"] = "Your explored map data was reset. Areas you uncovered earlier may be hidden again."
            }, this);
        }

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

        private void OnFogOfWarStale(BasePlayer player)
        {
            if (player == null || !config.SendNotice) return;

            string id = player.UserIDString;
            float now = UnityEngine.Time.realtimeSinceStartup;

            float last;
            if (lastNotice.TryGetValue(id, out last) && now - last < config.CooldownSeconds) return;

            lastNotice[id] = now;
            player.ChatMessage(Msg("Notice", id));
        }

        private void Unload()
        {
            lastNotice.Clear();
        }
    }
}

The plugin keeps a nested PluginConfig with a toggle and a configurable cooldown, loaded through the standard config overrides. OnFogOfWarStale records the current UnityEngine.Time.realtimeSinceStartup per user id in a dictionary, but only sends a chat line when the configured cooldown has elapsed since that player's last notice, which prevents repeated messages if the server rebuilds fog data several times in a row. All player-facing text goes through the language file with a Msg helper. Unload clears the timer reference, and config changes are re-read at startup so admins can tune behavior without touching code.

Common use cases

  • Map reset notifications

    Inform a player in chat that their explored map data was reset, so they understand why previously revealed areas are hidden again.

  • Diagnostics for map issues

    Count fog resets per player into a data file to spot clients or accounts that keep getting their fog data rebuilt, which can indicate a map or save problem.

  • Combine with OnFogOfWarCleared

    Pair this hook with OnFogOfWarCleared to distinguish a stale-data rebuild from an explicit fog clear triggered elsewhere.

Pitfalls

  • You cannot cancel the reset

    The hook fires after the lists are cleared and refilled, and its return value is ignored, so there is no way to keep the old fog data from a plugin.

  • Do not spam chat

    The method can run more than once for the same player during a session, so gate messages behind a cooldown or a per-session flag.

  • Fires per player

    On a full server this handler runs once per affected player, so keep the body short and avoid expensive lookups inside it.

Build a plugin with OnFogOfWarStale

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

Prompt: Map reset notifications using the OnFogOfWarStale 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 OnFogOfWarStale

Generate