Skip to content
RustPluginGenerator

OnFogOfWarCleared

OnFogOfWarCleared is called after BasePlayer.ServerClearFog wipes a player's explored-map fog data, before the server dirties player state and resends fog images to the client.

Signature
void OnFogOfWarCleared(BasePlayer player, bool mainland, bool deepSea)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer whose fog of war was just cleared. Can be null-checked like any hook parameter; the server passes the instance whose ServerClearFog ran.
mainlandboolTrue when the mainland fog list was cleared as part of this call. Reflects the mainland argument the server passed into ServerClearFog.
deepSeaboolTrue when the deep sea fog list was cleared as part of this call. Reflects the deepSea argument the server passed into ServerClearFog.

Return value

The return value is ignored. The server continues to DirtyPlayerState() and SendFogImagesToClient() regardless of what the hook returns, so you cannot cancel or alter the fog reset from here.

How it works

This hook fires inside BasePlayer.ServerClearFog, right after the server clears the requested fog lists and before it calls DirtyPlayerState() and SendFogImagesToClient(). That method is the server-side routine that resets a player's explored map fog, so the hook fires whenever that reset happens for a connected player, such as an admin clearing map fog through the game's own command path. It does not fire on every map reveal or fog image update; those go through separate paths.

The player parameter is the affected player, so you can key logging, rewards, permissions or UI on them. mainland and deepSea tell you which regions were reset in this call, which lets you distinguish a partial clear from a full one. Because the hook fires before fog images are resent, client-side map state has not been refreshed at call time.

Declaring a narrower type does not help here: the first parameter is already BasePlayer. The two bools are plain values. There is no way to prevent the clear from this hook, since it fires after the wipe.

Example plugin: Reward players with a map item when their fog is cleared

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

namespace Oxide.Plugins
{
    [Info("Fog Clear Reward", "RustPluginGenerator", "1.0.0")]
    [Description("Gives players a reward when their explored mainland fog is cleared")]
    public class FogClearReward : RustPlugin
    {
        private const string PermReward = "fogclearreward.reward";

        private PluginConfig config;
        private readonly Dictionary<ulong, float> cooldowns = new Dictionary<ulong, float>();

        private class PluginConfig
        {
            [JsonProperty("Give reward when mainland fog cleared")]
            public bool RewardMainland { get; set; } = true;

            [JsonProperty("Reward item shortname")]
            public string ItemShortname { get; set; } = "map";

            [JsonProperty("Reward amount")]
            public int Amount { get; set; } = 1;

            [JsonProperty("Require permission")]
            public bool RequirePermission { get; set; } = true;

            [JsonProperty("Cooldown seconds")]
            public float CooldownSeconds { get; set; } = 60f;
        }

        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>
            {
                ["Reward"] = "Your explored map was reset. Here is a {0} x{1}.",
                ["NoPermission"] = "You do not have permission to receive fog reset rewards."
            }, this);
        }

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

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

        private void OnFogOfWarCleared(BasePlayer player, bool mainland, bool deepSea)
        {
            if (player == null || !player.IsConnected) return;
            if (!mainland || !config.RewardMainland) return;
            if (config.RequirePermission && !permission.UserHasPermission(player.UserIDString, PermReward)) return;

            float now = UnityEngine.Time.realtimeSinceStartup;
            float last;
            if (cooldowns.TryGetValue(player.userID, out last) && now - last < config.CooldownSeconds) return;
            cooldowns[player.userID] = now;

            var def = ItemManager.FindItemDefinition(config.ItemShortname);
            if (def == null)
            {
                PrintWarning("Invalid reward item shortname in config: " + config.ItemShortname);
                return;
            }

            var item = ItemManager.CreateByItemID(def.itemid, config.Amount);
            if (item == null) return;

            player.GiveItem(item);
            player.ChatMessage(Msg("Reward", player.UserIDString, def.displayName.english, config.Amount));
        }
    }
}

The plugin listens for OnFogOfWarCleared and, when the reset covers the mainland, gives the player a small in-game reward through their inventory. It uses a config toggle so admins can disable rewards, and a permission to restrict who qualifies. The item shortname comes from config, and the code checks that the definition exists before creating it so a bad config value cannot throw. Rewards are announced via a localized chat message. A cooldown per player prevents repeated grants if an admin clears fog several times in a row.

Common use cases

  • Admin audit logging

    Record who had their map fog reset and which regions were affected, writing the entry to an oxide/data log for later review.

  • Compensation on fog reset

    Hand out an item or currency when a player's mainland exploration is wiped, to soften the loss of discovered locations.

  • Notify the player

    Send a chat message explaining that the explored map was reset and whether the deep sea map was affected too.

Pitfalls

  • Fires after the wipe

    The fog lists are already cleared when the hook runs, so you cannot block or partially undo the reset from here.

  • Client map is not yet updated

    The server resends fog images after the hook returns, so any client-side map or UI you read at call time still reflects the old state.

  • Bools can be false together in odd cases

    Guard against both region flags being false if the server calls the routine without a valid region, and do not assume at least one is always true.

Build a plugin with OnFogOfWarCleared

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

Prompt: Admin audit logging using the OnFogOfWarCleared 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 OnFogOfWarCleared

Generate