Jump to content
Sign in to follow this  
whiztler

Spectator mode after respawn tickets run out.

Recommended Posts

Does anyone have any idea how to enable the spectator mode AFTER the respawn tickets run out. Now I have:

respawn = "BASE";
respawnDelay = 300;
respawnTemplatesWest[] = {"Counter", "Tickets", "Spectator"};

But with this option spectator mode is enabled when players are waiting to respawn, meaning they can see the entire map.

I am want the spectator mode to kick in once ALL the tickets have been used up.

Share this post


Link to post
Share on other sites

BIS_fnc_selectRespawnTemplate:

/*
   Author: Karel Moricky

   Description:
   Select respawn template from CfgRespawnTemplates and execute its script / function

   Parameter(s):
       0: STRING - engine script which called the function
       1: ARRAY - script arguments

   Returns:
   ARRAY of SCRIPTs
*/

_mode = [_this,0,"",[""]] call bis_fnc_param;
_args = [_this,1,[],[[]]] call bis_fnc_param;

//--- Get engine respawn
_respawn = 0 call bis_fnc_missionRespawnType;

//--- Detect what script was called
_isDeath = false;
switch (_mode) do {

   //--- Death (NONE): [<unit>,<killer>]
   case "playerKilledScript": {
       _respawn = 0;
       _isDeath = true;
   };

   //--- Death (INSTANT, BASE): [<oldUnit>,<killer>,<respawnDelay>]
   case "playerRespawnScript": {
       _args resize 2;
       missionnamespace setvariable ["BIS_fnc_selectRespawnTemplates_args",[_args select 0]];
       _isDeath = true;
   };

   //--- Respawn (BIRD, GROUP, SIDE): [<unit>,<killer>,<seagull>]
   case "playerRespawnSeagullScript": {
       _args = [_args select 2,_args select 0];
       _respawn = 1;
   };

   //--- Respawn (INSTANT, BASE, GROUP): [<newUnit>]
   case "playerResurrectScript": {
       if (_respawn == 4) then {_respawn = -1;};
       _args = _args + (missionnamespace getvariable ["BIS_fnc_selectRespawnTemplates_args",[objnull]]);
   };

   //--- Respawn (GROUP, SIDE): [<oldUnit>,<killer>,<newUnit>]
   case "playerRespawnOtherUnitScript": {
       _args = [_args select 2,_args select 0];
   };

   //--- Forced respawn
   case "initRespawn": {
       if !(_respawn in [2,3]) then {_respawn = -1;};
       _isDeath = true;
   };

   //--- Death: [objnull,objnull,objnull]
   case "initRespawnStart": {
       if !(_respawn in [2,3]) then {_respawn = -1;};
       _isDeath = true;
   };

   //--- Respawn: [objnull,objnull,objnull]
   case "initRespawnEnd": {
       if !(_respawn in [2,3]) then {_respawn = -1;};
   };
};

//--- Terminate when playerResurrectScript is triggered in GROUP respawn to prevent duplicate call
if (_respawn < 0) exitwith {[]};

//--- Get respawn templates
_respawnTemplates = [configfile >> "CfgRespawnTemplates","respawnTemplates" + (["",_respawn] call bis_fnc_missionRespawnType)] call bis_fnc_returnconfigentry;
if (ismultiplayer || _mode in ["initRespawn","initRespawnStart","initRespawnEnd"]) then {
   _playerside = if (player call bis_fnc_isUnitVirtual) then {"VIRTUAL"} else {str (player call bis_fnc_objectSide)};
   _respawnTemplates = [missionconfigfile,"respawnTemplates",_respawnTemplates] call bis_fnc_returnconfigentry;
   _respawnTemplates = [missionconfigfile,"respawnTemplates" + _playerside,_respawnTemplates] call bis_fnc_returnconfigentry;
};
if (typename _respawnTemplates != typename []) then {_respawnTemplates = [_respawnTemplates];};

//--- Forced respawn
_respawnOnStart = false;
if (_isDeath && alive player) then {
   if (ismultiplayer) then {
       if (isnumber (missionconfigfile >> "respawnOnStart")) then {
           _respawnOnStart = getnumber (missionconfigfile >> "respawnOnStart") > 0;
       } else {
           {
               _cfgRespawn = [["CfgRespawnTemplates",_x],configfile] call bis_fnc_loadClass;
               if (_cfgRespawn != configfile) then {
                   _respawnOnStart = _respawnOnStart || (getnumber (_cfgRespawn >> "respawnOnStart") > 0);
               };
           } foreach _respawnTemplates;
       };
   };
   if (_respawnOnStart) then {
       player setpos [10,10,10];
       player hideobject true;
       player enablesimulation false;
       forcerespawn player;
   } else {
       _isDeath = false;
   };
};
if (_respawnOnStart) exitwith {[]};

//--- Increase respawn count (displayed in the debriefing screen)
if (_isDeath && ismultiplayer) then {["BIS_fnc_missionHandlers_reloads",1] call bis_fnc_counter;};

//--- Show loading screen to speed up the process when respawning
if !(_isDeath) then {["bis_fnc_selectRespawnTemplate","RscDisplayLoadingBlack"] call bis_fnc_startloadingscreen;};

//--- Calculate respawn delay
_respawnDelay = ([missionconfigfile,"respawnDelay",-1] call bis_fnc_returnconfigentry) call bis_fnc_parsenumber;
_scriptName = if (_isDeath) then {"onPlayerKilled"} else {"onPlayerRespawn"};
_scripts = [];
{
   _cfgRespawn = [["CfgRespawnTemplates",_x],configfile] call bis_fnc_loadClass;
   if (_cfgRespawn != configfile) then {

       //--- Template specific respawn delay
       if (_respawnDelay < 0) then {
           _respawnDelay = ([_cfgRespawn,"respawnDelay",-1] call bis_fnc_returnconfigentry) call bis_fnc_parsenumber;
           if (_respawnDelay >= 0) then {setplayerrespawntime _respawnDelay;};
       };
   };
} foreach _respawnTemplates;
_respawnDelay = _respawnDelay max 0;

//--- Execute codes
{
   _cfgRespawn = [["CfgRespawnTemplates",_x],configfile] call bis_fnc_loadClass;
   if (_cfgRespawn != configfile) then {

       //--- Get the code
       _scriptPath = gettext (_cfgRespawn >> _scriptName);
       if (_scriptPath != "") then {
           _code = missionnamespace getvariable _scriptPath;
           _codeType = "function";
           if (isnil {_code}) then {
               _code = compile preprocessfilelinenumbers _scriptPath;
               _codeType = "file";
           };

           //--- Execute the code
           _script = (_args + [_respawn,_respawnDelay]) spawn _code;
           _scripts set [count _scripts,_script];
           ["%4 template '%1' executed from %2 '%3'",_x,_codeType,_scriptPath,_scriptName] call bis_fnc_logFormat;
       } else {
           //["'%1' entry is missing in respawn template '%2'.",_scriptName,_x] call bis_fnc_error;
       };
   } else {
       ["Respawn template '%1' not found.",_x] call bis_fnc_error;
   };
} foreach _respawnTemplates;

//--- Execute mission respawn
_script = (_args + [_respawn,_respawnDelay]) spawn compile preprocessfilelinenumbers (_scriptName + ".sqf");
_scripts set [count _scripts,_script];

//--- End the loading screen after short delay
if !(_isDeath) then {
   [] spawn {
       "bis_fnc_selectRespawnTemplate" call bis_fnc_endloadingscreen;
   };
   if !(player getvariable ["bis_fnc_selectRespawnTemplate_respawned",false]) then {
       player setvariable ["bis_fnc_selectRespawnTemplate_respawned",true,true]; //--- ToDo: Remove once engine solution is implemented
   };
};

_scripts

When a player dies, and in my case has to wait 5 minutes to respawn, the spectator script should not fire-up. Having looked at the spectator function (BIS fnc respawnSpectator) and the tickets fnc (BIS fnc respawnTickets) I am not entirely sure if an answer to my question is possible.

Share this post


Link to post
Share on other sites

You may need to add a killed EH to each player that calls into a script that has a couple checks to see what the ticket count is and if the ticket count is less than or equal to zero then switch the respawn template:

//Pseudo code

if !([] call BIS_fnc_respawnTickets >= 0) exitWith { hint "There are still tickets left"; };

if ([] call BIS_fnc_respawnTickets <= 0) then { 

//execute spectator mode

};

Share this post


Link to post
Share on other sites

If you want to retirve a particular side's tickets

[ west, 0 ] call BIS_fnc_respawnTickets <= 0

Share this post


Link to post
Share on other sites
You may need to add a killed EH to each player that calls into a script that has a couple checks to see what the ticket count is and if the ticket count is less than or equal to zero then switch the respawn template:
If you want to retirve a particular side's tickets

This still doesn't solve the issue of enabling the spectator mode AFTER the respawn tickets run out. Currently players have spectator/bird mode while they wait for respawn (counter). It does work fine when all tickets are gone. My issue is when there are still tickets avail and players have to wait 5 min before they can respawn. During those 5 minutes they now can check out the entire AO with the spectator mode which is a major spoiler.

Basically I need to disable the spectator function in the killed EH when tickets > 0. The information on the spectator function is quite scarse.

Share this post


Link to post
Share on other sites

Oh. Use a killed eh (or w/e you like) and disable the spectator via script with:

( "BIS_fnc_respawnSpectator" call BIS_fnc_rscLayer ) cutText [ "", "PLAIN" ];

You can re-create it using EH to:


 _unit = _this select 0;

if ([ west, 0 ] call BIS_fnc_respawnTickets <= 0) then {
if ( side _unit == WEST ) then {
	_layer = "BIS_fnc_respawnSpectator" call bis_fnc_rscLayer;
	_layer cutrsc ["RscSpectator","plain"];  
};
};

---------- Post added at 00:47 ---------- Previous post was at 00:38 ----------

Edited it a bit. Cheers.

Edited by Iceman77

Share this post


Link to post
Share on other sites

Thanks Iceman, but see the OP. Specatormode with tickets like it says in the OP works fine. It kicks in when players die when there are tickets left and when there are no tickets left. I am looking for a sollution where the specatot mode DOES NOT KICK IN when players are waiting to respawn for 300 seconds ( = when there are still tickets left). It should ONLY KICK IN when players die and threre are no tickets left. The BIS_fnc_selectRespawnTemplate and BIS_fnc_respawnSpectator do not offer any useful information (both wiki and config viewer).

Share this post


Link to post
Share on other sites

yes I just posted how to disable the spectator display... and how to re-add it ( if needed ). And also the condition inwhich too.. Not sure what else you want? :)

Share this post


Link to post
Share on other sites

Thanks buddy. Did try something similar. But will try your solution. Thanks!

Share this post


Link to post
Share on other sites

just noticed there's also another spectator display. try this too: ("RscSpectator_fade" call bis_fnc_rscLayer) cutText["","plain"];

Cheers

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
Sign in to follow this  

×