diff --git a/addons/sitting/XEH_clientInit.sqf b/addons/sitting/XEH_clientInit.sqf index 23816bd8d77..a167e0fea54 100644 --- a/addons/sitting/XEH_clientInit.sqf +++ b/addons/sitting/XEH_clientInit.sqf @@ -3,9 +3,16 @@ // Exit on Headless if (!hasInterface) exitWith {}; -// Add interaction menu exception -["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition); +["SettingsInitialized", { + TRACE_1("SettingInit", GVAR(enable)); + + //If not enabled, then do not add CanInteractWith Condition or event handlers: + if (!GVAR(enable)) exitWith {}; -// Handle interruptions -["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); -["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); + // Add interaction menu exception + ["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition); + + // Handle interruptions + ["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); + ["SetHandcuffed", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); +}] call EFUNC(common,addEventHandler); diff --git a/addons/sitting/functions/fnc_addSitActions.sqf b/addons/sitting/functions/fnc_addSitActions.sqf index 18779d9229d..98c9aba99f3 100644 --- a/addons/sitting/functions/fnc_addSitActions.sqf +++ b/addons/sitting/functions/fnc_addSitActions.sqf @@ -16,19 +16,28 @@ #include "script_component.hpp" params ["_seat"]; -private ["_type", "_sitAction"]; -_type = typeOf _seat; +private _type = typeOf _seat; // Exit if the object is not specified as a seat if (getNumber (configFile >> "CfgVehicles" >> _type >> QGVAR(canSit)) != 1) exitWith {}; +// only run this after the settings are initialized +if !(EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addSitActions), _this]; +}; + +//If not enabled, don't add actions: +if (!GVAR(enable)) exitWith {}; + // Exit if class already initialized if (_type in GVAR(initializedClasses)) exitWith {}; GVAR(initializedClasses) pushBack _type; -_sitAction = [ +TRACE_1("Adding Sit Action",_type); + +private _sitAction = [ QGVAR(Sit), localize LSTRING(Sit), QUOTE(PATHTOF(UI\sit_ca.paa)), diff --git a/addons/sitting/functions/fnc_getRandomAnimation.sqf b/addons/sitting/functions/fnc_getRandomAnimation.sqf index ca9a9ccfb10..ed49b11e925 100644 --- a/addons/sitting/functions/fnc_getRandomAnimation.sqf +++ b/addons/sitting/functions/fnc_getRandomAnimation.sqf @@ -15,10 +15,8 @@ */ #include "script_component.hpp" -private "_animations"; - // Animations Pool -_animations = [ +private _animations = [ QGVAR(HubSittingChairA_idle1), QGVAR(HubSittingChairA_idle2), QGVAR(HubSittingChairA_idle3), diff --git a/addons/sitting/functions/fnc_sit.sqf b/addons/sitting/functions/fnc_sit.sqf index 24245699bc3..7aa1c4c55bc 100644 --- a/addons/sitting/functions/fnc_sit.sqf +++ b/addons/sitting/functions/fnc_sit.sqf @@ -16,15 +16,13 @@ */ #include "script_component.hpp" -private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_seatPosOrig"]; - params ["_seat", "_player"]; // Overwrite weird position, because Arma decides to set it differently based on current animation/stance... _player switchMove "amovpknlmstpsraswrfldnon"; // Add scroll-wheel action to release object -_actionID = _player addAction [ +private _actionID = _player addAction [ format ["%1", localize LSTRING(Stand)], QUOTE((_this select 0) call FUNC(stand)), nil, @@ -36,9 +34,9 @@ _actionID = _player addAction [ ]; // Read config -_configFile = configFile >> "CfgVehicles" >> typeOf _seat; -_sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection)); -_sitPosition = getArray (_configFile >> QGVAR(sitPosition)); +private _configFile = configFile >> "CfgVehicles" >> typeOf _seat; +private _sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection)); +private _sitPosition = getArray (_configFile >> QGVAR(sitPosition)); // Get random animation and perform it (before moving player to ensure correct placement) [_player, call FUNC(getRandomAnimation), 2] call EFUNC(common,doAnimation); // Correctly places when using non-transitional animations @@ -55,7 +53,7 @@ _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple peop // Add automatical stand PFH in case of interruptions -_seatPosOrig = getPosASL _seat; +private _seatPosOrig = getPosASL _seat; [{ params ["_args", "_pfhId"]; _args params ["_player", "_seat", "_seatPosOrig"]; diff --git a/addons/sitting/functions/fnc_stand.sqf b/addons/sitting/functions/fnc_stand.sqf index 4c08461746e..a51f4203fc6 100644 --- a/addons/sitting/functions/fnc_stand.sqf +++ b/addons/sitting/functions/fnc_stand.sqf @@ -16,7 +16,6 @@ #include "script_component.hpp" params ["_player"]; -private ["_animation"]; (_player getVariable QGVAR(isSitting)) params ["_seat", "_actionID"]; @@ -24,7 +23,7 @@ private ["_animation"]; _player removeAction _actionID; // Restore animation -_animation = switch (currentWeapon _player) do { +private _animation = switch (currentWeapon _player) do { case "": {"amovpercmstpsnonwnondnon"}; case (primaryWeapon _player): {"amovpercmstpslowwrfldnon"}; case (handgunWeapon _player): {"amovpercmstpslowwpstdnon"};