OnEntityFlagsNetworkUpdate
OnEntityFlagsNetworkUpdate is called on the server just before a BaseEntity sends its network flag update to connected clients, and returning a non-null value skips that transmission entirely.
object OnEntityFlagsNetworkUpdate(BaseEntity entity)Parameters
| Parameter | Type | Description |
|---|---|---|
entity | BaseEntity | The BaseEntity whose network flag state is about to be written and sent to subscribers. It can be any networked entity, so check the concrete type before acting on it. |
Return value
Returning null lets the original method run and the flag update is written and sent to subscribers. Returning any non-null value stops the original transmission, so the entity's flag changes are not broadcast on that call; the return value itself is discarded because the method returns void.
How it works
The hook fires from BaseEntity.SendNetworkUpdate_Flags, the method that packs the entity's current flags (open, on, locked, busy, and so on) into a network write and sends it to every subscribed connection. This makes it a low-level networking hook: it runs frequently for any entity that changes state, including doors, storage containers, ovens, turrets, vehicles and loot crates.
The only parameter is the entity being updated. Because the hook has no type filter on the injection, you get every networked entity, not just one class. Test entity as StorageContainer, entity as Door and similar casts to react only to the prefabs you care about. Reading entity.HasFlag(BaseEntity.Flags.Open) here shows the state that is about to be sent.
Returning a non-null value suppresses the flag transmission for that entity on that call. The internal state still changes on the server; only the network write is skipped. Use this sparingly and think about what clients will see: other update paths (position, parent, inventory) can still push data, so a skipped flag write does not fully hide an entity. The method runs often, so keep the body cheap and never print to console.
Example plugin: Freeze network flag updates on a chosen entity
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("Flag Update Freezer", "RustPluginGenerator", "1.0.0")]
[Description("Allows admins to suppress network flag updates for a chosen entity.")]
public class FlagUpdateFreezer : RustPlugin
{
private const string PermUse = "flagupdatefreezer.use";
private readonly HashSet<ulong> frozen = new HashSet<ulong>();
private void Init()
{
permission.RegisterPermission(PermUse, this);
}
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
["Frozen"] = "Flag updates suppressed for {0} ({1}).",
["Unfrozen"] = "Flag updates restored for {0} ({1}).",
["NoEntity"] = "Look at an entity and run the command again.",
["NoPermission"] = "You do not have permission to use this command."
}, this);
}
private string Msg(string key, string userId = null, params object[] args)
{
return string.Format(lang.GetMessage(key, this, userId), args);
}
[ChatCommand("flagfreeze")]
private void CmdFlagFreeze(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!permission.UserHasPermission(player.UserIDString, PermUse))
{
player.ChatMessage(Msg("NoPermission", player.UserIDString));
return;
}
BaseEntity entity = FindLookedAtEntity(player);
if (entity == null)
{
player.ChatMessage(Msg("NoEntity", player.UserIDString));
return;
}
ulong id = entity.net.ID.Value;
string label = entity.ShortPrefabName ?? "entity";
if (frozen.Remove(id))
{
player.ChatMessage(Msg("Unfrozen", player.UserIDString, label, id));
}
else
{
frozen.Add(id);
player.ChatMessage(Msg("Frozen", player.UserIDString, label, id));
}
}
private object OnEntityFlagsNetworkUpdate(BaseEntity entity)
{
if (entity == null || entity.net == null) return null;
if (frozen.Contains(entity.net.ID.Value))
{
return true;
}
return null;
}
private BaseEntity FindLookedAtEntity(BasePlayer player)
{
RaycastHit hit;
if (Physics.Raycast(player.eyes.position, player.eyes.HeadForward(), out hit, 10f))
{
return hit.GetEntity();
}
return null;
}
private void Unload()
{
frozen.Clear();
}
}
}Admins run /flagfreeze while looking at an entity. The command records the entity's net.ID.Value in a HashSet<ulong> and confirms in chat. From then on OnEntityFlagsNetworkUpdate checks the set and returns a non-null object for matching entities, which skips the flag broadcast for that entity. Running /flagfreeze again while looking at the same entity removes it from the set, so updates resume on the next state change. The set lives in memory only and is cleared on plugin unload, which keeps the plugin simple and avoids persisting entity ids that may no longer exist after a server restart. The hook body is two cheap lookups, which is important because it fires constantly.
Common use cases
Diagnosing noisy flag traffic
Temporarily suppress flag updates for one entity to confirm whether a visual bug on the client comes from flag syncing or from another update path.
Holding a visual state open
Keep a door or container showing a stale open/locked flag on clients for a scripted event by returning non-null until the event ends.
Selective entity handling by type
Cast the entity and only act on specific classes, such as StorageContainer, so unrelated entities flow through the hook untouched.
Pitfalls
It does not block other update paths
Skipping the flag write does not stop position, parent or inventory network updates. Clients can still receive data about the entity, so do not treat this as a full hide.
Server state and client state diverge
Flags change server-side regardless of the return value. Other players may see stale visuals until a later update clears the suppression, so scope suppression tightly and in time.
Hot path - keep it trivial
The hook runs for every networked flag change on the server. Avoid LINQ, allocations and logging in the body; a set or dictionary lookup is the right weight.
Build a plugin with OnEntityFlagsNetworkUpdate
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 OnEntityFlagsNetworkUpdate
Generate