Stored scroll-wheel action ID into already existing player setVariable instead of having 2

This commit is contained in:
jonpas 2015-09-27 01:37:19 +02:00
parent dbd0beb514
commit 85cff04e0c
2 changed files with 7 additions and 16 deletions

View File

@ -24,12 +24,6 @@ params ["_seat", "_player"];
_player switchMove "amovpknlmstpsraswrfldnon";
// Add scroll-wheel action to release object
_actionID = _player getVariable [QGVAR(StandUpActionID), -1];
if (_actionID != -1) then {
_player removeAction _actionID;
};
_actionID = _player addAction [
format ["<t color='#FFFF00'>%1</t>", localize LSTRING(Stand)],
QUOTE((_this select 0) call FUNC(stand)),
@ -41,8 +35,6 @@ _actionID = _player addAction [
QUOTE(_this call FUNC(canStand))
];
_player setVariable [QGVAR(StandUpActionID), _actionID];
// Read config
_configFile = configFile >> "CfgVehicles" >> typeOf _seat;
_sitDirection = (getDir _seat) + getNumber (_configFile >> QGVAR(sitDirection));
@ -58,7 +50,7 @@ _player setDir _sitDirection;
_player setPos (_seat modelToWorld _sitPosition);
// Set variables, save seat object on player
_player setVariable [QGVAR(isSitting), _seat];
_player setVariable [QGVAR(isSitting), [_seat, _actionID]];
_seat setVariable [QGVAR(seatOccupied), true, true]; // To prevent multiple people sitting on one seat

View File

@ -16,12 +16,14 @@
#include "script_component.hpp"
params ["_player"];
private ["_animation"];
// Remove scroll wheel action
_player removeAction (_player getVariable [QGVAR(StandUpActionID), -1]);
(_player getVariable QGVAR(isSitting)) params ["_seat", "_actionID"];
// Remove scroll-wheel action
_player removeAction _actionID;
// Restore animation
private "_animation";
_animation = switch (currentWeapon _player) do {
case "": {"amovpercmstpsnonwnondnon"};
case (primaryWeapon _player): {"amovpercmstpslowwrfldnon"};
@ -31,10 +33,7 @@ _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];
if (isNull _seat) exitWith {};
_seat setVariable [QGVAR(seatOccupied), nil, true];