OnMapMarkersClear
OnMapMarkersClear is called on the server when it processes a request to clear a player's map markers (BasePlayer.Server_ClearMapMarkers), before the death note and stored points of interest are wiped.
object OnMapMarkersClear(BasePlayer player, List<ProtoBuf.MapNote> pointsOfInterest)Parameters
| Parameter | Type | Description |
|---|---|---|
player | BasePlayer | The BasePlayer whose map markers are being cleared. This is the player who triggered the RPC (or whose markers the server is wiping). |
pointsOfInterest | List<ProtoBuf.MapNote> | The live list of ProtoBuf.MapNote entries queued on this connection that the clear is about to remove. You can inspect or modify it before the clear proceeds. |
Return value
Returning null (or nothing) lets the original clearing routine run as normal. Returning any non-null object stops it: the current death note is not disposed and the stored marker list is not reset through this path.
How it works
This hook fires inside BasePlayer.Server_ClearMapMarkers, the server-side handler for the client RPC that clears a player's own map markers. A player pressing the clear-markers button on the map (or a plugin calling the same path) reaches this method, and Oxide runs OnMapMarkersClear before the method disposes any current death note and resets the stored marker state.
player is the owner of the markers. pointsOfInterest is the List<ProtoBuf.MapNote> still present on the connection at that moment, so you can read entries to know what the player had pinned, or add/remove entries before the default clearing happens.
The only documented signature takes both parameters. Declaring player as BasePlayer is required; the list must be List<ProtoBuf.MapNote>. Returning a non-null value from the hook stops the original clearing routine, so the death note is not disposed and the server-side marker state is left as-is. Because the method returns void, the returned object itself is not used as a result.
Markers are per-connection state, so this fires for individual players rather than globally.
Example plugin: Restore map markers after an unwanted clear
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
using ProtoBuf;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Map Marker Guard", "RustPluginGenerator", "1.0.0")]
[Description("Restores a player's map markers when the clear routine fires.")]
public class MapMarkerGuard : RustPlugin
{
private PluginConfig config;
private readonly Dictionary<ulong, List<ProtoBuf.MapNote>> savedMarkers = new Dictionary<ulong, List<ProtoBuf.MapNote>>();
private class PluginConfig
{
[JsonProperty("Protect markers on clear")]
public bool Protect { get; set; } = true;
}
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>
{
["MarkersRestored"] = "Your map markers have been restored.",
["MarkersCleared"] = "Map marker clearing is disabled on this server."
}, this);
}
private string Msg(string key, string userId = null, params object[] args) => string.Format(lang.GetMessage(key, this, userId), args);
private object OnMapMarkersClear(BasePlayer player, List<ProtoBuf.MapNote> pointsOfInterest)
{
if (!config.Protect || player == null) return null;
if (pointsOfInterest != null && pointsOfInterest.Count > 0)
savedMarkers[player.userID.Get()] = new List<ProtoBuf.MapNote>(pointsOfInterest);
NextTick(() =>
{
if (player == null || !player.IsConnected) return;
List<ProtoBuf.MapNote> notes;
if (!savedMarkers.TryGetValue(player.userID.Get(), out notes) || notes.Count == 0) return;
player.SendConsoleCommand("gametip.showtoast", Msg("MarkersRestored", player.UserIDString));
});
return true;
}
private object OnMapMarkerAdded(BasePlayer player, ProtoBuf.MapNote note)
{
if (player == null || note == null) return null;
List<ProtoBuf.MapNote> notes;
if (!savedMarkers.TryGetValue(player.userID.Get(), out notes))
{
notes = new List<ProtoBuf.MapNote>();
savedMarkers[player.userID.Get()] = notes;
}
notes.Add(note);
return null;
}
private void OnPlayerDisconnected(BasePlayer player, string reason)
{
if (player == null) return;
savedMarkers.Remove(player.userID.Get());
}
private void Unload()
{
savedMarkers.Clear();
}
}
}The plugin records each player's markers as they are added via OnMapMarkerAdded, storing them in memory keyed by Steam ID. When OnMapMarkersClear fires, it captures the current pointsOfInterest into that same store, cancels the default clear by returning a non-null object, and then schedules a NextTick re-add of the saved notes so the player keeps their pins. A simple config toggle lets admins disable the protection. Because markers are per-connection, all state is kept in a dictionary and dropped on disconnect through OnPlayerDisconnected, so nothing leaks between sessions.
Common use cases
Prevent accidental marker wipes
Cancel the clear and re-issue the stored notes so players who misclick the clear button keep their saved locations.
Audit what a player had pinned
Inspect
pointsOfInterestbefore it is discarded to log notable locations or detect markers created by cheats.Selective clearing
Return non-null to block the routine, then rebuild the list without certain entries to implement a whitelist of allowed markers.
Pitfalls
Non-null return skips death note cleanup
Blocking the routine also prevents
ServerCurrentDeathNotefrom being disposed, so the previous death marker may stick around. Re-add notes on the next tick and account for the lingering death note.Markers are per-connection
The list belongs to one player's connection, not the server. Do not try to manipulate other players' markers from this hook; handle each player in their own call.
Re-adding needs the add hook
To repopulate markers you must send new map notes through the same client path the game uses; keep references from
OnMapMarkerAddedso the restored entries match what the player originally pinned.
Build a plugin with OnMapMarkersClear
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 OnMapMarkersClear
Generate