Stored a global variable in player setVariable

This commit is contained in:
jonpas 2015-09-27 01:31:23 +02:00
parent a7a716ca8d
commit dbd0beb514
6 changed files with 13 additions and 12 deletions

View File

@ -18,6 +18,7 @@ class Extended_Killed_EventHandlers {
};
};
// Need initPost or there are problems with setVariable
class Extended_InitPost_EventHandlers {
class All {
class ADDON {

View File

@ -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);

View File

@ -18,4 +18,4 @@
params ["_player"];
// Sitting
(_player getVariable [QGVAR(isSitting), false])
!isNil {_player getVariable QGVAR(isSitting)}

View File

@ -17,6 +17,6 @@
params ["_player"];
if (_player getVariable [QGVAR(isSitting), false]) then {
if (!isNil {_player getVariable QGVAR(isSitting)}) then {
_player call FUNC(stand);
};

View File

@ -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)]);
};

View File

@ -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];