ACE3/addons/common/functions/fnc_moveToTempGroup.sqf

32 lines
1.0 KiB
Plaintext
Raw Normal View History

2015-01-16 23:21:47 +00:00
/**
* fn_moveToTempGroup_f.sqf
* Moves a unit into a temporarly group and stores its original group to allow rejoining.
* @Author: Glowbal
*
* @Arguments: [unit OBJECT, moveToTempGroup BOOL]
* @Return: void
* @PublicAPI: false
*/
#include "script_component.hpp"
private ["_unit","_moveTo","_previousGroup","_newGroup", "_currentGroup", "_switchToGroup"];
_unit = [_this, 0,ObjNull,[ObjNull]] call BIS_fnc_Param;
_moveTo = [_this, 1,false,[false]] call BIS_fnc_Param;
if (_moveTo) then {
2015-01-18 19:09:19 +00:00
_previousGroup = group _unit;
_newGroup = createGroup (side _previousGroup);
[_unit] joinSilent _newGroup;
_unit setvariable [QGVAR(previousGroup),_previousGroup];
2015-01-16 23:21:47 +00:00
} else {
_previousGroup = _unit getvariable QGVAR(previousGroup);
2015-01-18 19:09:19 +00:00
if (!isnil "_previousGroup") then {
_currentGroup = group _unit;
_unit setvariable [QGVAR(previousGroup),nil];
2015-01-18 19:09:19 +00:00
[_unit] joinSilent _previousGroup;
if (count units _currentGroup == 0) then {
deleteGroup _currentGroup;
};
};
2015-01-16 23:21:47 +00:00
};