RustTip

IOnBasePlayerHurt

OxidePlayer
object IOnBasePlayerHurt(BasePlayer basePlayer, HitInfo info)
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

basePlayer
BasePlayer
info
HitInfo

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 IOnBasePlayerHurt(BasePlayer basePlayer, HitInfo info)
{
    Puts("IOnBasePlayerHurt");

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

Rust.opj (Oxide)
void BasePlayer.Hurt(HitInfo)

Passes: BasePlayer basePlayer, HitInfo info

Method changed — checkReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll

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

public override void Hurt(HitInfo info)
{
	if (IsDead() || IsTransferProtected() || (IsImmortalTo(info) && info.damageTypes.Total() >= 0f))
	{
		return;
	}
	if (Interface.CallHook("IOnBasePlayerHurt", this, info) != null)
	{
		return;
	}
	bool wasWounded = IsWounded();
	if (ConVar.Server.pve && !IsNpc && (bool)info.Initiator && info.Initiator is BasePlayer && info.Initiator != this)
	{
		(info.Initiator as BasePlayer).Hurt(info.damageTypes.Total(), DamageType.Generic);
		return;
// …

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.