RustTip

OnUserRespawn

OxideCarbonPlayer

Called when an user respawns.

void OnUserRespawn(Oxide.Core.Libraries.Covalence.IPlayer player)
Works — the game method in this build is the one the hook was written for.

Parameters

player
Oxide.Core.Libraries.Covalence.IPlayer

Return value

voidBehaviour is not described.

Example

private void OnUserRespawn(Oxide.Core.Libraries.Covalence.IPlayer player)
{
    Puts("OnUserRespawn");
}

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

Where it is called

Oxide core (Oxide.Rust)
RustCore::OnPlayerRespawn(BasePlayer basePlayer)

Oxide core code — the hook is called from here

private object OnPlayerRespawn(BasePlayer basePlayer)
{
    IPlayer player = basePlayer.IPlayer;
    return player != null ? Interface.CallHook("OnUserRespawn", player) : null;
}

Injection point 1

Rust.opj (Oxide)
void BasePlayer.Respawn()

Injected internal hook OnPlayerRespawn — this hook is called by its handler in the Oxide/Carbon core

WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (this, l0 => l0)Assembly-CSharp.dll

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

public void Respawn()
{
	SpawnPoint spawnPoint = ServerMgr.FindSpawnPoint(this, 0uL);
	if (Server.respawnAtDeathPosition && ServerCurrentDeathNote != null)
	{
		spawnPoint.pos = ServerCurrentDeathNote.worldPosition;
	}
	Interface.CallHook("OnPlayerRespawn", this, l0 => l0);
	RespawnAt(spawnPoint.pos, spawnPoint.rot);
}

Injection point 2

Rust.opj (Oxide)
bool SleepingBag.SpawnPlayer(BasePlayer, NetworkableId)

Injected internal hook OnPlayerRespawn — this hook is called by its handler in the Oxide/Carbon core

WorksReturnBehavior: UseArgumentStringArgumentBehavior: UseArgumentString (a0, l1 => l1)Assembly-CSharp.dll

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

// …
		sleepingBag2 = item;
		break;
	}
}
if (sleepingBag2 == null)
{
	return false;
}
Interface.CallHook("OnPlayerRespawn", player, l1 => l1);
if (sleepingBag2 is StaticRespawnArea staticRespawnArea && !staticRespawnArea.IsAuthed(player.userID))
{
	return false;
}
if (sleepingBag2.GetRespawnState(player.userID) != RespawnInformation.SpawnOptions.RespawnState.OK)
{
	return false;
}
// …

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.