RustTip

OnEntityDismounted

OxideCarbonEntity

Called to validate a player's dismount position before exiting a mount or vehicle.

void OnEntityDismounted(BaseMountable baseMountable, BasePlayer player)
Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.

Parameters

baseMountable
BaseMountable
player
BasePlayer

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnEntityDismounted(BaseMountable baseMountable, BasePlayer player)
{
    Puts("OnEntityDismounted");
}

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

Injection point 1

Rust.opj (Oxide)
void BaseMountable.DismountPlayer(BasePlayer, bool)

Passes: BaseMountable baseMountable, BasePlayer player

Method changed — checkReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

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

// …
		if ((bool)player.GetParentEntity())
		{
			BaseEntity baseEntity = player.GetParentEntity();
			player.ClientRPC(RpcTarget.Player("ForcePositionToParentOffset", player), baseEntity.transform.InverseTransformPoint(res), baseEntity.net.ID);
		}
		else
		{
			player.ClientRPC(RpcTarget.Player("ForcePositionTo", player), res);
			Interface.CallHook("OnEntityDismounted", this, player);
			player.ClientRPC(RpcTarget.NetworkGroup("ForceResetRotation"));
		}
	}
	Analytics.Azure.OnDismountEntity(player, this, baseVehicle);
	OnPlayerDismounted(player);
	SendNetworkUpdate();
}

Injection point 2

Rust.opj (Oxide)
void BaseMountable.DismountPlayer(BasePlayer, bool)

Passes: BaseMountable baseMountable, BasePlayer player

Method changed — checkReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, a0)Assembly-CSharp.dll

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

// …
	_mounted = null;
	if (baseVehicle != null)
	{
		baseVehicle.PlayerDismounted(player, this);
	}
	OnPlayerDismounted(player);
	return;
}
Interface.CallHook("OnEntityDismounted", this, player);
if (!GetDismountPosition(player, out var res) || Distance(res) > 10f)
{
	if (baseVehicle != null)
	{
		baseVehicle.PrePlayerDismount(player, this);
	}
	res = player.transform.position;
	_mounted.DismountObject();
// …

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.