Skip to content
RustPluginGenerator

OnMapMarkersCleared

OnMapMarkersCleared is called on the server after a player's map markers have been cleared on the server side, inside BasePlayer.Server_ClearMapMarkers.

Signature
void OnMapMarkersCleared(BasePlayer player)

Parameters

Hook parameters
ParameterTypeDescription
playerBasePlayerThe BasePlayer whose map markers were just cleared, after the game wiped State.pointsOfInterest and pushed the updated state to the player.

Return value

The return value is ignored: the hook is called after the clear has already happened and the original method returns void. Returning anything has no effect on the game.

How it works

This hook fires from BasePlayer.Server_ClearMapMarkers, at the end of the method: after the player's point-of-interest list has been emptied and the player state marked dirty and resynced to the client. It is the server-side companion notification, so it runs for whatever caused the clear (a client request, an admin action, or plugin code that calls the same method) rather than for each individual marker.

The only argument is the BasePlayer whose markers were cleared. It is always the owning player, so you can use player.UserIDString to look up data and player.ChatMessage or SendReply to give feedback. Because the signature is a single BasePlayer, declaring any base class or interface the argument derives from also matches; the usual and clearest choice is the exact type.

Use it when you keep your own marker bookkeeping or want to track clears. It fires rarely, so light logging or state resets are fine. The hook cannot stop the clear, and it does not report which markers existed beforehand, so snapshot them earlier with OnMapMarkerRemove if you need that detail.

Example plugin: Notify players and log when their map markers are cleared

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

namespace Oxide.Plugins
{
    [Info("Map Markers Cleared Notifier", "RustPluginGenerator", "1.0.0")]
    [Description("Notifies players and logs when their map markers are cleared on the server")]
    public class MapMarkersClearedNotifier : RustPlugin
    {
        private const string PermAdmin = "mapmarkersclearednotifier.admin";

        private PluginConfig config;
        private StoredData data;
        private readonly Dictionary<ulong, float> lastNotice = new Dictionary<ulong, float>();

        private class PluginConfig
        {
            [JsonProperty("Show chat message to player")]
            public bool ShowPlayerMessage { get; set; } = true;

            [JsonProperty("Notify online admins")]
            public bool NotifyAdmins { get; set; } = true;

            [JsonProperty("Cooldown between messages per player (seconds)")]
            public float CooldownSeconds { get; set; } = 10f;

            [JsonProperty("Track clear counts in data file")]
            public bool TrackCounts { get; set; } = true;
        }

        private class StoredData
        {
            [JsonProperty("Clear counts by player id")]
            public Dictionary<string, int> Counts { get; set; } = new Dictionary<string, int>();
        }

        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>
            {
                ["MarkersCleared"] = "Your map markers have been cleared by the server.",
                ["AdminNotice"] = "{0} ({1}) had their map markers cleared."
            }, this);
        }

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

        private void Init()
        {
            permission.RegisterPermission(PermAdmin, this);
            data = Interface.Oxide.DataFileSystem.ReadObject<StoredData>(Name) ?? new StoredData();
        }

        private void Unload()
        {
            if (config.TrackCounts && data != null)
                Interface.Oxide.DataFileSystem.WriteObject(Name, data);
            lastNotice.Clear();
        }

        private void OnMapMarkersCleared(BasePlayer player)
        {
            if (player == null) return;

            string userId = player.UserIDString;
            float now = Time.realtimeSinceStartup;

            bool throttle = false;
            if (lastNotice.TryGetValue(player.userID.Get(), out float last) && now - last < config.CooldownSeconds)
                throttle = true;
            lastNotice[player.userID.Get()] = now;

            if (config.TrackCounts && data != null)
            {
                data.Counts.TryGetValue(userId, out int count);
                data.Counts[userId] = count + 1;
            }

            if (config.ShowPlayerMessage && !throttle)
                player.ChatMessage(Msg("MarkersCleared", userId));

            if (!config.NotifyAdmins) return;

            foreach (BasePlayer admin in BasePlayer.activePlayerList)
            {
                if (admin == null || admin == player || !admin.IsConnected) continue;
                if (!admin.IsAdmin && !permission.UserHasPermission(admin.UserIDString, PermAdmin)) continue;
                admin.ChatMessage(Msg("AdminNotice", admin.UserIDString, player.displayName, userId));
            }
        }
    }
}

The plugin listens for OnMapMarkersCleared and reacts to every server-side marker wipe. It keeps a per-player counter in oxide/data, increments it, and sends the player a localized chat line through the language file so the message is easy to translate. A configurable cooldown prevents spam if something repeatedly clears markers, and an optional admin notification broadcasts the event to online admins. On unload the data file is written so counts survive restarts. All player-facing text goes through lang, and the hook only does cheap in-memory work plus a throttled save.

Common use cases

  • Wipe tracking for custom maps

    Reset or rebuild any plugin-side marker lists for a player when the game clears their map, so custom maps stay in sync with the vanilla state.

  • Audit admin actions

    Log which player had markers cleared and when, useful when admins use commands that clear maps on populated servers.

  • Player feedback

    Send a short chat message confirming the clear so players understand why their custom waypoints disappeared.

Pitfalls

  • No marker details provided

    The hook only gives you the player. To know which markers were removed, capture them in OnMapMarkerRemove before the clear happens; this hook is purely a post-clear notification.

  • Cannot be cancelled

    It fires after State.pointsOfInterest has been cleared and synced. Returning a value does nothing, so do not try to prevent the clear from here.

  • Watch save frequency

    If you persist data here, throttle writes. Persistent state files are cheap per save but unnecessary on every clear when a client or plugin triggers clears often.

Build a plugin with OnMapMarkersCleared

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

Prompt: Wipe tracking for custom maps using the OnMapMarkersCleared 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 OnMapMarkersCleared

Generate