OnPlayerActionBroadcast
OnPlayerActionBroadcast is called by ConVar.Chat.BroadcastPlayerAction right before the chat log line about a player action is sent to every online player. Returning a non-null value suppresses that broadcast entirely.
object OnPlayerActionBroadcast(BasePlayer subject, string action)Parameters
| Parameter | Type | Description |
|---|---|---|
subject | BasePlayer | The player the outgoing action message is about. Check for null before using it, since the game logs this as a struct parameter. |
action | string | The action verb text the game would append, for example opening a loot container, already localized by the server. Not the player name. |
Return value
Returning null (or any value when nothing matches) lets the broadcast continue to all players. Returning a non-null object of any value, including false, stops the method before the message is sent and nobody sees it.
How it works
This hook fires from the game's chat logging routine, not from chat itself. The server calls ConVar.Chat.BroadcastPlayerAction when it wants to tell all connected players that someone performed a notable action, such as looting a container or using a world object. The single-subject overload runs when one player is involved; the two-subject overload with subjectA, middle, subjectB and suffix runs when the message pairs two players, for example one player looting another.
Both overloads exist under the same hook name, so a plugin can implement either or both. Oxide picks the method whose parameters all match the arguments it is passing, which is why you should declare the exact types. The subject argument is a struct-supplied player reference and should always be null-checked. The action string is the localized verb phrase, useful for filtering.
This hook runs on every such broadcast, so keep the body cheap: no Puts, no file access, no iterating all players. It is the right place to mute, rewrite or rate-limit these automatic action lines without touching chat messages players type.
Other signatures
Oxide also calls OnPlayerActionBroadcast from other places in the game with these parameter types. Declare the overload you need, or several:
object OnPlayerActionBroadcast(BasePlayer subjectA, string middle, BasePlayer subjectB, string suffix)
Example plugin: Suppress action broadcasts for hidden staff
using System.Linq;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Oxide.Core;
namespace Oxide.Plugins
{
[Info("Action Broadcast Filter", "RustPluginGenerator", "1.0.0")]
[Description("Suppresses automatic player action messages in chat for selected players")]
public class ActionBroadcastFilter : RustPlugin
{
private const string PermAdmin = "actionbroadcastfilter.admin";
private PluginConfig config;
private readonly HashSet<ulong> hidden = new HashSet<ulong>();
private class PluginConfig
{
[JsonProperty("Suppress all action broadcasts")]
public bool SuppressAll { get; set; } = false;
[JsonProperty("Player ids whose actions stay hidden")]
public List<ulong> HiddenPlayers { get; set; } = new List<ulong>();
}
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>
{
["Enabled"] = "Your action broadcasts are now hidden.",
["Disabled"] = "Your action broadcasts are visible again.",
["Denied"] = "You do not have permission to use this command."
}, this);
}
private string Msg(string key, string userId = null) => lang.GetMessage(key, this, userId);
private void Init()
{
permission.RegisterPermission(PermAdmin, this);
}
private void OnServerInitialized()
{
hidden.Clear();
foreach (ulong id in config.HiddenPlayers)
{
hidden.Add(id);
}
}
private object OnPlayerActionBroadcast(BasePlayer subject, string action)
{
if (subject == null) return null;
return ShouldHide(subject.userID) ? (object)true : null;
}
private object OnPlayerActionBroadcast(BasePlayer subjectA, string middle, BasePlayer subjectB, string suffix)
{
if ((subjectA != null && ShouldHide(subjectA.userID)) ||
(subjectB != null && ShouldHide(subjectB.userID)))
{
return true;
}
return null;
}
private bool ShouldHide(ulong userId)
{
if (config.SuppressAll) return true;
return hidden.Contains(userId);
}
[ChatCommand("actionmute")]
private void CmdActionMute(BasePlayer player, string command, string[] args)
{
if (player == null) return;
if (!permission.UserHasPermission(player.UserIDString, PermAdmin))
{
player.ChatMessage(Msg("Denied", player.UserIDString));
return;
}
ulong id = player.userID.Get();
if (hidden.Contains(id))
{
hidden.Remove(id);
config.HiddenPlayers.Remove(id);
player.ChatMessage(Msg("Disabled", player.UserIDString));
}
else
{
hidden.Add(id);
if (!config.HiddenPlayers.Contains(id)) config.HiddenPlayers.Add(id);
player.ChatMessage(Msg("Enabled", player.UserIDString));
}
SaveConfig();
}
private void Unload()
{
hidden.Clear();
}
}
}An admin toggles broadcast muting with /actionmute. The muted state lives in the config file, so it survives restarts. OnPlayerActionBroadcast is declared twice to cover both game overloads. Each method checks the config flag, then looks at every player argument and returns a non-null marker if any of them stands on the hidden list. Returning anything other than null stops BroadcastPlayerAction before it loops over the player list, so the line never reaches chat. Null-checks guard the player references, and the bodies stay allocation-free apart from a short list lookup, which matters because this hook fires on every logged action.
Common use cases
Hide staff actions from public chat
Admins looting crates would otherwise announce their presence through the automatic action line. Suppressing it keeps undercover moderation quiet.
Mute noisy event areas
During automated events with many container interactions, you can drop the action broadcasts temporarily to keep chat readable, then restore them on a timer.
Filter by action text
Inspect the action string and only suppress matching phrases, leaving other notifications intact.
Pitfalls
Two overloads, one hook name
The four-argument version with
subjectA,middle,subjectB,suffixcalls the same hook. If you only declare the two-argument method, paired messages still go through.Returning false does not mean allow
The game only checks whether the hook returned null. Returning
falsestill cancels the broadcast.Called very frequently
Do not log or query the data file inside this hook. Cache the decision in a field and rebuild it when the config or permission changes.
Build a plugin with OnPlayerActionBroadcast
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 OnPlayerActionBroadcast
Generate