Oxygen

OnPlayerRespawn

This hook is triggered when a player respawns after death. It provides information about the respawn method chosen by the player and the target sector.

Definition

public override void OnPlayerRespawn(PlayerBase player, PlayerRespawnData data) {}

Parameters

ParameterTypeDescription
playerPlayerBaseThe instance of the player who is respawning.
dataPlayerRespawnDataStructure containing details about the respawn location and type.

PlayerRespawnData Structure

This structure contains specific information about how and where the player is returning to the game.

FieldTypeDescription
SpawnLocationTypeintThe numerical ID of the spawn method (see Spawn Types below).
SectorXintThe X-coordinate of the map sector.
SectorYintThe Y-coordinate of the map sector.

Spawn Location Types (Enum)

ValueNameDescription
0NoneNo specific location.
1RandomStandard random map respawn.
2SectorRespawn within a specific chosen sector.
3HomeRespawn at a shelter or bed roll.
4SquadRespawn on a squad member.
5EventRespawn triggered by an active in-game event.

Usage Example

The following example logs the respawn details and greets the player if they respawned at their home base.

public override void OnPlayerRespawn(PlayerBase player, PlayerRespawnData data)
{
    // Convert sector coordinates to a readable format (e.g., B1)
    string sectorName = $"{(char)('A' + data.SectorX)}{data.SectorY}";
    
    Console.WriteLine($"[Respawn] {player.Name} spawned in {sectorName} using method ID: {data.SpawnLocationType}");

    // Check if the player spawned at Home (ID: 3)
    if (data.SpawnLocationType == 3)
    {
        player.Reply("Welcome home! Take care of your gear.", Color.Green);
    }
}

SECTOR LOGIC

The SectorX and SectorY values follow the game's grid system. For instance, SectorX = 0 is A, SectorX = 1 is B, and so on.

On this page