RustTip

OnPlayerActionBroadcast

OxideCarbonServer
object OnPlayerActionBroadcast(BasePlayer subject, string action)
object OnPlayerActionBroadcast(BasePlayer subjectA, string middle, BasePlayer subjectB, string suffix)
Works — the game method in this build is the one the hook was written for.

Parameters

subject
BasePlayer
action
string

Return value

objectReturn non-null to cancel the game action.

Example

object — you can affect the game: return a value to change or cancel the action.

private object OnPlayerActionBroadcast(BasePlayer subject, string action)
{
    Puts("OnPlayerActionBroadcast");

    // change nothing — the game continues as usual
    return null;

    // to affect the game:
    // return false; // non-null cancels the game action
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point 1

Rust.opj (Oxide)
void ConVar.Chat.BroadcastPlayerAction(BasePlayer, string)

Passes: BasePlayer subject, string action

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustParamsAssembly-CSharp.dll

Where it is called (this branch's game code)

public static void BroadcastPlayerAction(BasePlayer subject, string action)
{
	if (Interface.CallHook("OnPlayerActionBroadcast", subject, action) != null)
	{
		return;
	}
	foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
	{
		if (!(activePlayer == null) && activePlayer.net?.connection != null)
		{
			string text = ((subject != null) ? NameHelper.GetPlayerNameStreamSafe(activePlayer, subject) : "SERVER").EscapeRichText();
// …

Injection point 2

Rust.opj (Oxide)
void ConVar.Chat.BroadcastPlayerAction(BasePlayer, string, BasePlayer, string)

Passes: BasePlayer subjectA, string middle, BasePlayer subjectB, string suffix

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustParamsAssembly-CSharp.dll

Where it is called (this branch's game code)

public static void BroadcastPlayerAction(BasePlayer subjectA, string middle, BasePlayer subjectB, string suffix)
{
	if (Interface.CallHook("OnPlayerActionBroadcast", subjectA, middle, subjectB, suffix) != null)
	{
		return;
	}
	foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
	{
		if (!(activePlayer == null) && activePlayer.net?.connection != null)
		{
			string text = ((subjectA != null) ? NameHelper.GetPlayerNameStreamSafe(activePlayer, subjectA) : "SERVER").EscapeRichText();
// …

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.