ACE3/addons/arsenal/functions/fnc_removeBox.sqf
Grim 339cfa8024
Arsenal - Add support for modifying Virtual Items while opened (#9542)
* add support for mod. virt. items while opened

* updateUniqueItems

* execNextFrame

* add notification and TRACE

* remove debug

* Update addons/arsenal/functions/fnc_addVirtualItems.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Update addons/arsenal/functions/fnc_refresh.sqf

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* move to removeBox

* update english to plural, others are fine

* missing include

* directCall in refresh

---------

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2023-10-23 13:31:21 -04:00

50 lines
1.4 KiB
Plaintext

#include "..\script_component.hpp"
#include "..\defines.hpp"
/*
* Author: Alganthe, johnb43
* Remove arsenal from target.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Remove globally <BOOL> (default: true)
*
* Return Value:
* None
*
* Example:
* [_box, true] call ace_arsenal_fnc_removeBox
*
* Public: Yes
*/
params [["_object", objNull, [objNull]], ["_global", true, [true]]];
if (isNull _object) exitWith {};
private _id = _object getVariable QGVAR(initBoxJIP);
if (_global && {isMultiplayer} && {!isNil "_id"}) then {
// Remove event from JIP queue
[_id] call CBA_fnc_removeGlobalEventJIP;
// Reset JIP ID
_object setVariable [QGVAR(initBoxJIP), nil, true];
// Remove box for everyone
[QGVAR(removeBox), [_object, false]] call CBA_fnc_globalEvent;
// Remove from JIP
_object setVariable [QGVAR(virtualItems), nil, true];
} else {
_object setVariable [QGVAR(virtualItems), nil];
[_object, 0, ["ACE_MainActions", QGVAR(interaction)]] call EFUNC(interact_menu,removeActionFromObject);
[QGVAR(boxRemoved), _object] call CBA_fnc_localEvent;
};
// If the arsenal is already open, close arsenal display
if (!isNil QGVAR(currentBox) && {GVAR(currentBox) isEqualTo _object}) then {
[LLSTRING(noVirtualItems), false, 5, 1] call EFUNC(common,displayText);
// Delay a frame in case this is running on display open
[{(findDisplay IDD_ace_arsenal) closeDisplay 0}] call CBA_fnc_execNextFrame;
};