RustTip

CanSwapToSeat

OxidePlayer
object CanSwapToSeat(BasePlayer player, BaseMountable baseMountable)
object CanSwapToSeat(BasePlayer player, ModularCarSeat modularCarSeat)
Works — the game method in this build is the one the hook was written for.

Parameters

player
BasePlayer
baseMountable
BaseMountable

Return value

objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.

Example

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

private object CanSwapToSeat(BasePlayer player, BaseMountable baseMountable)
{
    Puts("CanSwapToSeat");

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

    // to affect the game:
    // return null; // null — the game continues as usual
}

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

Injection point 1

Rust.opj (Oxide)
bool BaseMountable.CanSwapToThis(BasePlayer)

Passes: BasePlayer player, BaseMountable baseMountable

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

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

public virtual bool CanSwapToThis(BasePlayer player)
{
	object returnvar = Interface.CallHook("CanSwapToSeat", player, this);
	if (returnvar is bool)
	{
		return (bool)returnvar;
	}
	return true;
}

Injection point 2

Rust.opj (Oxide)
bool ModularCarSeat.CanSwapToThis(BasePlayer)

Passes: BasePlayer player, ModularCarSeat modularCarSeat

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

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

public override bool CanSwapToThis(BasePlayer player)
{
	object returnvar = Interface.CallHook("CanSwapToSeat", player, this);
	if (returnvar is bool)
	{
		return (bool)returnvar;
	}
	if (associatedSeatingModule.DoorsAreLockable)
	{
		ModularCar modularCar = associatedSeatingModule.Vehicle as ModularCar;
		if (modularCar != null)
// …

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.