BIS_fnc_respawnManager
- Arma 3 v0.50
- First in Arma 2: Operation Arrowhead v1.50
Function · Markdown · JSON · original wiki page
Description
Respawn manager with checkpoints. Checkpoints are markers named "BIS_checkpointnr1", "BIS_checkpointnr2", ... (numbered without gaps); at least one must exist when the manager is initialised. "Init" creates the global logic BIS_RespawnManager that holds the manager's data and adds "Killed" and "Respawn" event handlers to the given units:
- when a unit dies, the checkpoint nearest to it is stored for it;
- when it respawns, the new unit gets the old unit's weapons and magazines. If a vehicle named <unitName>_Vehicle exists, it is respawned, moved to a safe position near the stored checkpoint (see BIS_fnc_findSafePos) and its crew is restored.
Every mode except "Init" returns false while the manager is not initialised. The function is meant to be called by mission scripts; no Arma 3 script calls it.
Important
- This is legacy Arma 2 code: the event handlers are added through the Arma 2 Multiplayer Framework function RE, which is not part of Arma 3's Functions Library.
- Parameters are passed on by format and compile: units must therefore have a variable name.
Syntax
Syntax 1
["Init", [respawners, safePositions], markerVisibility] call BIS_fnc_respawnManager
Parameters:
"Init": String - initialises the managerrespawners: Array of Objects - respawning unitssafePositions: Array of Positions - one position per unit, used when no safe position is found for its vehicle; when empty, [8179.12, 1881.57, 0] is used for every unitmarkerVisibility: String - (Optional, default "") "", "true" or "false"; every value currently results in checkpoint marker type "EMPTY"
Returns: Boolean - false if the manager was already initialised, otherwise true
Syntax 2
["Destroy"] call BIS_fnc_respawnManager
Parameters:
"Destroy": String - deletes the manager logic
Syntax 3
["AddCheckpoint", position, markerName] call BIS_fnc_respawnManager
Parameters:
"AddCheckpoint": String - creates a checkpoint marker and adds it to the listposition: Array format Position - checkpoint positionmarkerName: String - (Optional, default "") marker name; if empty, the next free "BIS_checkpointnrN" name is used
Syntax 4
["RemoveCheckpoint", markerName] call BIS_fnc_respawnManager
Parameters:
"RemoveCheckpoint": String - removes a checkpoint from the list and deletes its markermarkerName: String - checkpoint marker name
Returns: Boolean - true if removed, false if the marker is not a checkpoint or it is the last one
Syntax 5
["GetNearestCheckpoint", unit] call BIS_fnc_respawnManager
Parameters:
"GetNearestCheckpoint": String - returns the checkpoint stored for a unitunit: Object - one of the respawning units
Returns: String - marker name of the checkpoint stored for the unit, or the first checkpoint if none is stored
Examples
Example 1
// markers "BIS_checkpointnr1", "BIS_checkpointnr2" are placed in the mission
["Init", [[BIS_player1, BIS_player2], []]] call BIS_fnc_respawnManager;
["AddCheckpoint", getMarkerPos "BIS_village", "BIS_checkpointVillage"] call BIS_fnc_respawnManager;
["RemoveCheckpoint", "BIS_checkpointnr1"] call BIS_fnc_respawnManager;
See also
Arma 3: Respawn · BIS_fnc_addRespawnPosition · BIS_fnc_findSafePos