diff --git a/addons/sitting/CfgEventHandlers.hpp b/addons/sitting/CfgEventHandlers.hpp index bd13e623f0..8b3768a747 100644 --- a/addons/sitting/CfgEventHandlers.hpp +++ b/addons/sitting/CfgEventHandlers.hpp @@ -18,6 +18,7 @@ class Extended_Killed_EventHandlers { }; }; +// Need initPost or there are problems with setVariable class Extended_InitPost_EventHandlers { class All { class ADDON { diff --git a/addons/sitting/XEH_clientInit.sqf b/addons/sitting/XEH_clientInit.sqf index 9cf8278877..23816bd8d7 100644 --- a/addons/sitting/XEH_clientInit.sqf +++ b/addons/sitting/XEH_clientInit.sqf @@ -4,7 +4,7 @@ if (!hasInterface) exitWith {}; // Add interaction menu exception -["isNotSitting", {!((_this select 0) getVariable [QGVAR(isSitting), false])}] call EFUNC(common,addCanInteractWithCondition); +["isNotSitting", {isNil {(_this select 0) getVariable QGVAR(isSitting)}}] call EFUNC(common,addCanInteractWithCondition); // Handle interruptions ["medical_onUnconscious", {_this call DFUNC(handleInterrupt)}] call EFUNC(common,addEventhandler); diff --git a/addons/sitting/functions/fnc_canStand.sqf b/addons/sitting/functions/fnc_canStand.sqf index c516485a82..a051e1784e 100644 --- a/addons/sitting/functions/fnc_canStand.sqf +++ b/addons/sitting/functions/fnc_canStand.sqf @@ -18,4 +18,4 @@ params ["_player"]; // Sitting -(_player getVariable [QGVAR(isSitting), false]) +!isNil {_player getVariable QGVAR(isSitting)} diff --git a/addons/sitting/functions/fnc_handleInterrupt.sqf b/addons/sitting/functions/fnc_handleInterrupt.sqf index 328675c172..c7e0a545ff 100644 --- a/addons/sitting/functions/fnc_handleInterrupt.sqf +++ b/addons/sitting/functions/fnc_handleInterrupt.sqf @@ -17,6 +17,6 @@ params ["_player"]; -if (_player getVariable [QGVAR(isSitting), false]) then { +if (!isNil {_player getVariable QGVAR(isSitting)}) then { _player call FUNC(stand); }; diff --git a/addons/sitting/functions/fnc_sit.sqf b/addons/sitting/functions/fnc_sit.sqf index 61872dd1a0..1b6f979b42 100644 --- a/addons/sitting/functions/fnc_sit.sqf +++ b/addons/sitting/functions/fnc_sit.sqf @@ -20,9 +20,6 @@ private ["_actionID", "_configFile", "_sitDirection", "_sitPosition", "_seatPosO params ["_seat", "_player"]; -// Set global variable for standing up -GVAR(seat) = _seat; //@todo - put into player isSitting variable - // Overwrite weird position, because Arma decides to set it differently based on current animation/stance... _player switchMove "amovpknlmstpsraswrfldnon"; @@ -60,8 +57,8 @@ _player setDir _sitDirection; // No need for ATL/ASL as modelToWorld returns in format position _player setPos (_seat modelToWorld _sitPosition); -// Set variables -_player setVariable [QGVAR(isSitting), true]; +// Set variables, save seat object on player +_player setVariable [QGVAR(isSitting), _seat]; _seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat @@ -72,7 +69,7 @@ _seatPosOrig = getPosASL _seat; _args params ["_player", "_seat", "_seatPosOrig"]; // Remove PFH if not sitting any more - if !(_player getVariable [QGVAR(isSitting), false]) exitWith { + if (isNil {_player getVariable QGVAR(isSitting)}) exitWith { [_pfhId] call CBA_fnc_removePerFrameHandler; TRACE_1("Remove PFH",_player getVariable [ARR_2(QGVAR(isSitting), false)]); }; diff --git a/addons/sitting/functions/fnc_stand.sqf b/addons/sitting/functions/fnc_stand.sqf index ef19d5f586..4c56eba1c4 100644 --- a/addons/sitting/functions/fnc_stand.sqf +++ b/addons/sitting/functions/fnc_stand.sqf @@ -17,7 +17,7 @@ params ["_player"]; -// remove scroll wheel action +// Remove scroll wheel action _player removeAction (_player getVariable [QGVAR(StandUpActionID), -1]); // Restore animation @@ -31,7 +31,10 @@ _animation = switch (currentWeapon _player) do { [_player, _animation, 2] call EFUNC(common,doAnimation); +// Get seat from variable on player +_seat = _player getVariable [QGVAR(isSitting), objNull]; +if (isNull _seat) exitWith {}; + // Set variables to nil _player setVariable [QGVAR(isSitting), nil]; -GVAR(seat) setVariable [QGVAR(seatOccupied), nil, true]; -GVAR(seat) = nil; +_seat setVariable [QGVAR(seatOccupied), nil, true];