OnPlayerRespawn
OxideCarbonPlayerCalled when a player respawns.
object OnPlayerRespawn(BasePlayer basePlayer, object l0 => l0)Works — the game method in this build is the one the hook was written for.
Parameters
- basePlayer
- BasePlayer
- l0 => l0
- object
Return value
objectThe returned value modifies the result, the game continues.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnPlayerRespawn(BasePlayer basePlayer, object l0 => l0)
{
Puts("OnPlayerRespawn");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return default(BasePlayer.SpawnPoint); // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void BasePlayer.Respawn()
Passes: BasePlayer basePlayer, object l0 => l0
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)
Passes: BasePlayer player, object l1 => l1
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.