RustTip

OnEntitySnapshot

OxideCarbonEntity

Called when a remote RCON command is received.

Provides access to the raw RCON message so you can log or modify behavior.

object OnEntitySnapshot(BaseNetworkable baseNetworkable, Network.Connection connection)
object OnEntitySnapshot(BaseNetworkable ent, object connection)
Works — the game method in this build is the one the hook was written for.

Parameters

baseNetworkable
BaseNetworkable
connection
Network.Connection

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 OnEntitySnapshot(BaseNetworkable baseNetworkable, Network.Connection connection)
{
    Puts("OnEntitySnapshot");

    // 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 BaseNetworkable.SendAsSnapshot(Network.Connection, bool)

Passes: BaseNetworkable baseNetworkable, Network.Connection connection

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

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

public void SendAsSnapshot(Connection connection, bool ordered = true)
{
	if (Interface.CallHook("OnEntitySnapshot", this, connection) != null)
	{
		return;
	}
	NetWrite netWrite = Net.sv.StartWrite();
	uint val = (ordered ? (++connection.validate.entityUpdates) : uint.MaxValue);
	SaveInfo saveInfo = new SaveInfo
	{
		forConnection = connection,
// …

Injection point 2

Rust.opj (Oxide)
void BasePlayer.SendEntitySnapshot(BaseNetworkable)

Passes: BaseNetworkable ent, object connection

WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (a0, this.net.connection)Assembly-CSharp.dll

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

private void SendEntitySnapshot(BaseNetworkable ent)
{
	if (Interface.CallHook("OnEntitySnapshot", ent, this.net.connection) != null)
	{
		return;
	}
	using (TimeWarning.New("SendEntitySnapshot"))
	{
		if (!(ent == null) && ent.net != null && ent.ShouldNetworkTo(this))
		{
			NetWrite netWrite = Net.sv.StartWrite();
// …

Injection point 3

Rust.opj (Oxide)
void BaseNetworkable.SendAsSnapshot(Network.Connection, Network.NetWrite, ref BaseNetworkable.ThreadSafeTime, bool)

Passes: BaseNetworkable baseNetworkable, Network.Connection connection

WorksReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

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

public void SendAsSnapshot(Connection connection, NetWrite write, in ThreadSafeTime time, bool ordered = true)
{
	uint val = (ordered ? (++connection.validate.entityUpdates) : uint.MaxValue);
	if (Interface.CallHook("OnEntitySnapshot", this, connection) != null)
	{
		return;
	}
	SaveInfo saveInfo = new SaveInfo
	{
		forConnection = connection,
		forDisk = false,
		cachedTime = time
// …

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.