Jump to content
Sign in to follow this  
elec

elec's HeadLessClient Auto Detection Switch

Recommended Posts

elec's HeadLessClient Auto Detection Switch

Hi there,

i wrote a script to auto-detect a headlessclient and let the mission be able to choose it to spawn units or do script stuff on it.

Basically it's just a "auto" switch that ask if a HC is connected. If so, your scripts - like upsmon or whatever - will execute on it. If not the scripts will run on the server like normal.

The thing is, you don't have to be change your "if (!isServer) exitWith{};" every time you build a headlessclient mission local to test it.

Also if you want to build a mission that should be able to spawn your units on a headless client but it should be also run if no headless client is available or something like that.

I have build a example mission to test out the proper working of the script. You can spawn units whit a radio trigger and check in the sidechat where they running.

Also i have implemented a switch that you can force HC or Server execution if you need

fwoj7ZU.jpg

xsVnkll.jpg

Copy "elec_HC_detect.sqf" into your mission folder and add this code in the !! FIRST !! line of your init.sqf:

elec_HC_detect = ["auto"] execVM "elec_HC_detect.sqf"; waitUntil {scriptDone elec_HC_detect};
//	========SWITCH========
// 	Use "auto" to autodetect if a headless client is connected and force execution on it.
// 	Use "on" to force the execution of your scripts on the HC, even he is not connected to the server. 
//	(so your scripts won't execute if no HC is connected to the server)
// 	Use "off" to force server execution. 

//	Replace your 
	if(!isserver)exitWith{};
// 	line with 
	if(elec_stop_exec == 1) exitWith{};
//	in your scripts, that you want to execute over the switch.

If you have any question just use this thread to ask. :)

Share this post


Link to post
Share on other sites

Nice idea,

Should make testing HC missions a little less painful.

Share this post


Link to post
Share on other sites

I just tested this with ARMA 3, did a minor change to the debug script to make that one work. The rest worked like a charm!

Thanks a million for this, this has saved me from headache. THANK YOOOU!!!11!!!11

SSG Loves you for this.

Share this post


Link to post
Share on other sites

This is the debug_hint.sqf working in Arma 3!

//debug_hint.sqf to let you know that it works

   hint "debug!";
   playerunits = 0;
   hcunits = 0;
   svunits = 0;
   PAPABEAR=[West,"HQ"];
   while{true}do{
           if(hasinterface) then {
                   _unitss = {local _x} count allUnits;
                   _jochen = "LOCALunits: ";
                   _zeige = _jochen + str(_unitss);
                   [-2, {player groupChat Format ["%1",_this];}, _zeige] call CBA_fnc_globalExecute; //[PAPABEAR,nil,rsideChat,_zeige] call RE;
           };

           if(!hasinterface && !isServer) then {
                   _unitss = {local _x}count allUnits;
                   _jochen = "HEADLESSunits: ";
                   _zeige = _jochen + str(_unitss);
                   [-2, {player groupChat Format ["%1",_this];}, _zeige] call CBA_fnc_globalExecute;
           };

           if(isServer) then {
                   _unitss = {local _x}count allUnits;
                   _jochen = "SERVERunits: ";
                   _zeige = _jochen + str(_unitss);
                   [-2, {player groupChat Format ["%1",_this];}, _zeige] call CBA_fnc_globalExecute;
           };
           sleep 5;
   };

Thanks to Pellejones and numrollen!

Edited by killshot

Share this post


Link to post
Share on other sites

Has anyone been able to get this to work fully with A3? I've found one problem.

Have this as the first line of my init.sqf:

elec_HC_detect = [] execVM "miscScripts\elec_HC_detect.sqf"; 
waitUntil {scriptDone elec_HC_detect};

Also have this as the top line of my "AI Spawning" scripts that are run at the end of of my init.sqf.

if(elec_stop_exec == 1) exitWith{};

I'm getting the following results:

1) 'Server' / Game being hosted on a players machine, AI called in my scripts spawn correctly.

2) Dedicated Server with a Headless Client connected, AI called in my scripts spawn correctly.

3) Dedicated Server, no headless client connected. AI called in my scripts never spawn.

Anyone run into anything similar, or have any ideas?

Share this post


Link to post
Share on other sites

this is great. does it work for arma 3????

Share this post


Link to post
Share on other sites

does anyone know if this works completely with arma 3??

If so could you give me details?

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  

×