RustTip

CanUseHelicopter

OxideCarbonVehicle

Called to determine whether to use helicopter.

Return true to allow the action and false to block it.

object CanUseHelicopter(BasePlayer player, CH47HelicopterAIController cH47HelicopterAIController)
Works — the game method in this build is the one the hook was written for.

Parameters

player
BasePlayer
cH47HelicopterAIController
CH47HelicopterAIController

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 CanUseHelicopter(BasePlayer player, CH47HelicopterAIController cH47HelicopterAIController)
{
    Puts("CanUseHelicopter");

    // 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 CH47HelicopterAIController.AttemptMount(BasePlayer, bool)

Passes: BasePlayer player, CH47HelicopterAIController cH47HelicopterAIController

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

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

public override void AttemptMount(BasePlayer player, bool doMountChecks = true)
{
	if (Interface.CallHook("CanUseHelicopter", player, this) != null)
	{
		return;
	}
	if (player.IsNpc || player.IsAdmin)
	{
		base.AttemptMount(player, doMountChecks);
	}
}

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.