Jump to content
CY4

Respawn Command/Script for One-Life Missions?

Recommended Posts

Hello all,
I'm wanting to be able to run one-life missions, so a player enters spectator mode immediately after dying, but I want some command or script the admin can run to respawn a player if they get killed due to a glitch or are disconnected. Certainly, this has to be possible somehow?
Any help is appreciated.

Share this post


Link to post
Share on other sites

You can create your own respawn behavior by using onPlayerRespawn.sqf and onPlayerKilled.sqf. You can keep a player in the spectator mode by setting his respawn timer to a high value, 1e+6 (10^6) for example. If you want him to respawn you can set his respawn time to a lower value again, for example 0 for instant respawn. For example:

description.ext

respawn = 3;
respawnDelay = 1e+6;
respawnTemplates[] = { "Base" };
respawnOnStart = -1;

onPlayerKilled.sqf

sleep 5;
["Initialize", [
	_unit, // spectator
	[west], // allowed sides
	false, // allow AI
	false, // allow free camera
	false, // allow 3rd person camera
	true, // show focus info
	false, // show camera buttons
	false, // show controls helper
	true, // show header
	true // show lists
]] call BIS_fnc_EGSpectator;

onPlayerRespawn.sqf:

params ["_player", "", "", "_delay"];
if (alive _player) then {
	//--- Player is not spectating, do nothing
	if !(["IsSpectating"] call BIS_fnc_EGSpectator) exitWith {false};
	//--- Player can be respawned from spectator
	// You might want to move the player to a specified position here, eg
    // [_player, /*position*/, false] call BIS_fnc_moveToRespawnPosition;
	["Terminate"] call BIS_fnc_EGSpectator;
	setPlayerRespawnTime _delay;
	true
} else {
	//--- Player is dead
	// Do stuff here before player respawns
	//--- Respawn player
	setPlayerRespawnTime 3;
	false
};

Not sure if this does work. I copied it from one of my missions and removed unnecessary bits,

  • Like 1

Share this post


Link to post
Share on other sites

Thank you, I will give it a try

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×