mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Fix global behavior in add / remove virtual items funcs (#5887)
This commit is contained in:
parent
845f3656d4
commit
5fa0179d06
@ -5,6 +5,9 @@ GVAR(EH_ID) = 0;
|
||||
GVAR(lastSearchTextLeft) = "";
|
||||
GVAR(lastSearchTextRight) = "";
|
||||
|
||||
[QGVAR(addVirtualItems), {_this call FUNC(addVirtualItems)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(removeVirtualItems), {_this call FUNC(removeVirtualItems)}] call CBA_fnc_addEventHandler;
|
||||
|
||||
[QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler;
|
||||
[QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler;
|
||||
|
||||
|
@ -24,6 +24,10 @@ params [["_object", objNull, [objNull]], ["_items", [], [true, []]], ["_global",
|
||||
if (_object == objNull) exitWith {};
|
||||
if (_items isEqualType [] && {count _items == 0}) exitWith {};
|
||||
|
||||
if (_global && {isMultiplayer}) then {
|
||||
[QGVAR(addVirtualItems), [_object, _items, false]] call CBA_fnc_globalEvent;
|
||||
|
||||
} else {
|
||||
private _cargo = _object getVariable [QGVAR(virtualItems), [
|
||||
[[], [], []], // Weapons 0, primary, secondary, handgun
|
||||
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
|
||||
@ -47,7 +51,8 @@ private _cargo = _object getVariable [QGVAR(virtualItems), [
|
||||
|
||||
private _configCfgWeapons = configFile >> "CfgWeapons"; //Save this lookup in variable for perf improvement
|
||||
|
||||
if (_items isEqualType true && {_items}) then {
|
||||
if (_items isEqualType true) then {
|
||||
if (_items) then {
|
||||
private _configItems = uiNamespace getVariable QGVAR(configItems);
|
||||
|
||||
{
|
||||
@ -67,7 +72,7 @@ if (_items isEqualType true && {_items}) then {
|
||||
(_cargo select _index) append (_configItems select _index);
|
||||
_cargo set [_index, (_cargo select _index) arrayIntersect (_cargo select _index)];
|
||||
};
|
||||
|
||||
};
|
||||
} else {
|
||||
{
|
||||
if (_x isEqualType "") then {
|
||||
@ -220,4 +225,5 @@ if (_items isEqualType true && {_items}) then {
|
||||
} foreach _items;
|
||||
};
|
||||
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
_object setVariable [QGVAR(virtualItems), _cargo];
|
||||
};
|
||||
|
@ -23,6 +23,10 @@ params [ ["_object", objNull, [objNull]], ["_items", [], [true, [""]]], ["_globa
|
||||
if (_object == objNull) exitWith {};
|
||||
if (_items isEqualType [] && {count _items == 0}) exitWith {};
|
||||
|
||||
if (_global && {isMultiplayer}) then {
|
||||
[QGVAR(removeVirtualItems), [_object, _items, false]] call CBA_fnc_globalEvent;
|
||||
|
||||
} else {
|
||||
private _cargo = _object getVariable [QGVAR(virtualItems), [
|
||||
[[], [], []], // Weapons 0, primary, handgun, secondary
|
||||
[[], [], [], []], // WeaponAccessories 1, optic,side,muzzle,bipod
|
||||
@ -44,9 +48,11 @@ private _cargo = _object getVariable [QGVAR(virtualItems), [
|
||||
[ ] // InventoryItems 17
|
||||
]];
|
||||
|
||||
if (_items isEqualType true && {_items}) then {
|
||||
if (_items isEqualType true) then {
|
||||
if (_items) then {
|
||||
[_object, _global] call FUNC(removeBox);
|
||||
_object setVariable [QGVAR(virtualItems), nil, _global];
|
||||
};
|
||||
} else {
|
||||
|
||||
// Make sure all items are in string form
|
||||
@ -72,9 +78,10 @@ if (_items isEqualType true && {_items}) then {
|
||||
};
|
||||
} count _cargo;
|
||||
|
||||
_object setVariable [QGVAR(virtualItems), _cargo];
|
||||
|
||||
if (_itemCount == 0) then {
|
||||
[_object, _global] call FUNC(removeBox);
|
||||
} else {
|
||||
_object setVariable [QGVAR(virtualItems), _cargo, _global];
|
||||
[_object, false] call FUNC(removeBox);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user