RustTip

OnPlayerVoice

OxideCarbonPlayer

Called when player voice occurs.

object OnPlayerVoice(BasePlayer basePlayer, ArraySegment<byte> arraySegment)
Works — the game method in this build is the one the hook was written for.

Parameters

basePlayer
BasePlayer
arraySegment
ArraySegment<byte>

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 OnPlayerVoice(BasePlayer basePlayer, ArraySegment<byte> arraySegment)
{
    Puts("OnPlayerVoice");

    // 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

Rust.opj (Oxide)
void ServerMgr.OnPlayerVoice(Network.Message)

Passes: BasePlayer basePlayer, ArraySegment<byte> arraySegment

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (l0, l1)Assembly-CSharp.dll

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

private void OnPlayerVoice(Message packet)
{
	BasePlayer basePlayer = packet.Player();
	if (!(basePlayer == null))
	{
		ArraySegment<byte> arraySegment = packet.read.BytesSegmentWithSize(1048576u);
		if (arraySegment.Count <= ConVar.Server.maxpacketsize_voicedata)
		{
			if (Interface.CallHook("OnPlayerVoice", basePlayer, arraySegment) != null)
			{
				return;
			}
			basePlayer.OnReceivedVoice(arraySegment);
		}
	}
}

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.