ACE3/addons/headless/functions/fnc_handleDisconnect.sqf
jonpas 6ca9d59443
Merge ACEX (#8415)
* Merge ACEX - first attempt
Backwards compatibility with XGVAR set of macros used on all settings and config entries
Public API functions not taken into account yet, many other things probably still missed

* Resolve issues

* Switch to addSetting, backward compatible CfgPatches, missed XGVAR.

* Remove unnecessary backwards compat

* Convert ACEX Categorised settings to initSettings / Fix Intel items magazine

* Apply suggestions from code review

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Remove maintainers from merged ACEX components

* Cleanup unused module and faction classes

* Sitting - Add more object configs by @Dystopian
https://github.com/acemod/ACEX/pull/255

* Translations - Add Japanese by @classicarma
https://github.com/acemod/ACEX/pull/259

* Kill Tracker - Add killtracker.inc public include file by @Freddo3000"
https://github.com/acemod/ACEX/pull/251

* Add ACEX authors and sort authors file

* acex - final tweaks (#8513)

* acex - handle old funcs

* replace thirst/hunger setvars to acex naming

fix macro

Revert "fix macro"

This reverts commit d807e5e804c43916eaa42d34a89af94c6d9a48ad.

Revert "replace thirst/hunger setvars to acex naming"

This reverts commit bafc607884932d6e339daedc7c22e25dddbdd868.

x

Co-authored-by: TyroneMF <TyroneMF@hotmail.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2021-10-14 10:46:43 -05:00

64 lines
1.8 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Jonpas
* Removes Headless Client from use.
* Ends mission if setting enabled and only Headless Clients are still connected.
*
* Arguments:
* 0: Object <OBJECT>
*
* Return Value:
* Transfer To Server <BOOL>
*
* Example:
* [unit] call ace_headless_fnc_handleDisconnect
*
* Public: No
*/
params ["_object"];
TRACE_1("HandleDisconnect",_this);
// Exit if not HC
if !(_object in GVAR(headlessClients)) exitWith {
TRACE_2("Object not in HC list",_object,GVAR(headlessClients));
// End mission when no players present
if (XGVAR(endMission) != 0 && {!GVAR(endMissionCheckDelayed)}) then {
// Delay check until 2.5 minutes into the mission - wait for allPlayers to sync
if (CBA_missionTime < 150) then {
TRACE_1("Mission start delay",CBA_missionTime);
GVAR(endMissionCheckDelayed) = true;
[{
call FUNC(endMissionNoPlayers);
}, [], 150 - CBA_missionTime] call CBA_fnc_waitAndExecute;
} else {
// End instantly or after delay
if (XGVAR(endMission) == 1) then {
TRACE_2("Instant end",GVAR(endMission),CBA_missionTime);
call FUNC(endMissionNoPlayers);
} else {
TRACE_2("Delayed 60s end",GVAR(endMission),CBA_missionTime);
GVAR(endMissionCheckDelayed) = true;
[FUNC(endMissionNoPlayers), [], 60] call CBA_fnc_waitAndExecute;
};
};
};
false
};
// Exit if AI distribution is disabled
if (!XGVAR(enabled)) exitWith {true};
// Remove HC
GVAR(headlessClients) deleteAt (GVAR(headlessClients) find _object);
if (XGVAR(log)) then {
INFO_1("Removed HC: %1",_object);
};
// Rebalance
[true] call FUNC(rebalance);
// Prevent transferring of HC to server
false