Jump to content

Recommended Posts

Hello lads! I am currently working on a short script for life limited scenarios I run for my group. The idea is to allow them to select respawn points from the respawn screen but only allow for two lives. If they die twice, they must respawn at the base and cannot deploy in the field any longer. After their second respawn they are moved to spectator. There seems to be a problem on dedicated server however: the MHQ respawn point is not removed after the first respawn. When I, logged in as the group leader and server admin run through it however, it removes the MHQ spawn point for all even if they haven`t died yet. Code is below; does anyone have any ideas? I am guessing it likely has something to do with the function`s global effect.

 

hint "First Life...";
playerDeaths = 0;
playerDiedOnce = false;
playerDiedTwice = false;

player addEventHandler ["Respawn", {playerDeaths = playerDeaths + 1}];

while {true && !playerDiedOnce} do {
	if (playerDeaths == 1) then {
		hint "Second Life...";
		player addEventHandler ["Killed", {respawn2 call BIS_fnc_removeRespawnPosition;}]; //respawn position is not removed after the first death; if the group leader/admin dies once however the position is removed for all
		playerDiedOnce = true;
	};
	sleep 1;
};

waitUntil {playerDiedOnce};

while {true && !playerDiedTwice} do {
	if (playerDeaths == 2) then {
		titleText ["You are out of lives. Now spectating...", "PLAIN"];
		["Initialize", [player, [playerSide], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
		playerDiedTwice = true;
		[player] joinSilent grpNull;
		player setPos position spectatorPos;
	};
sleep 1;
};

 

Share this post


Link to post
Share on other sites

BIS_fnc_removeRespawnPosition takes two parameters. the first specifies whose respawn will be removed, the second one is the id of the respawn. I assume that you got respawn2 as a return value from BIS_fnc_addRespawnPosition so if you pass it as is to BIS_fnc_removeRespawnPosition then it will get removed from everyone that got the respawn position via your addRespawnPosition call. Instead you should only remove it from the player that died:

[player, respawn2 select 1] call BIS_fnc_removeRespawnPosition;

 

Share this post


Link to post
Share on other sites
7 hours ago, 7erra said:

BIS_fnc_removeRespawnPosition takes two parameters. the first specifies whose respawn will be removed, the second one is the id of the respawn. I assume that you got respawn2 as a return value from BIS_fnc_addRespawnPosition so if you pass it as is to BIS_fnc_removeRespawnPosition then it will get removed from everyone that got the respawn position via your addRespawnPosition call. Instead you should only remove it from the player that died:


[player, respawn2 select 1] call BIS_fnc_removeRespawnPosition;

 

 

Hello mate, thanks for the reply! Unfortunately this doesn`t seem to have remedied the issue. Now it seems that the respawn point is not removed for anyone. I will attach the new behavior.

 

First trip to respawn screen: 8eziXFD.png

 

Second trip to respawn screen: VYeieRr.png

 

 

If you are curious, this is what I have in my initPlayerLocal.sqf:

execVM "handleSpectator.sqf";

respawn1 = [playerSide,base,"FOB"] call BIS_fnc_addRespawnPosition;

respawn2 = [playerSide,mhq,"MHQ"] call BIS_fnc_addRespawnPosition;

 

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

×