From 1693e6834dfeb2c39ce760e1d12a19d40632565b Mon Sep 17 00:00:00 2001 From: TACHarsis <101965352+TACHarsis@users.noreply.github.com> Date: Sat, 18 Feb 2023 03:59:23 +0100 Subject: [PATCH] Added `ace_rearm_sourceInitialized` event (#9134) --- addons/rearm/functions/fnc_makeSource.sqf | 20 +++++++++++--------- docs/wiki/framework/rearm-framework.md | 6 ++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/addons/rearm/functions/fnc_makeSource.sqf b/addons/rearm/functions/fnc_makeSource.sqf index c697925380..51aa515cdf 100644 --- a/addons/rearm/functions/fnc_makeSource.sqf +++ b/addons/rearm/functions/fnc_makeSource.sqf @@ -43,14 +43,16 @@ _source setVariable [QGVAR(currentSupply), _currentSupply + _rearmCargo, true]; private _rearmCargoConfig = getNumber (configOf _source >> QGVAR(defaultSupply)); -// already initialized because this is a config rearm vehicle -if (_rearmCargoConfig > 0 || _source getVariable [QGVAR(isSupplyVehicle), false]) exitWith {}; +// initialize if it's not a config rearm vehicle +if (!(_rearmCargoConfig > 0 && _source getVariable [QGVAR(isSupplyVehicle), false])) then { + _source setVariable [QGVAR(isSupplyVehicle), true, true]; -_source setVariable [QGVAR(isSupplyVehicle), true, true]; + // only add if menu does not already exist + if (isNil {_source getVariable QGVAR(initSupplyVehicle_jipID)}) then { + private _jipID = [QGVAR(initSupplyVehicle), [_source]] call CBA_fnc_globalEventJIP; + [_jipID, _source] call CBA_fnc_removeGlobalEventJIP; + _source setVariable [QGVAR(initSupplyVehicle_jipID), _jipID]; + }; +}; -// check if menu already exists -if (!isNil {_source getVariable QGVAR(initSupplyVehicle_jipID)}) exitWith {}; - -private _jipID = [QGVAR(initSupplyVehicle), [_source]] call CBA_fnc_globalEventJIP; -[_jipID, _source] call CBA_fnc_removeGlobalEventJIP; -_source setVariable [QGVAR(initSupplyVehicle_jipID), _jipID]; +[QGVAR(rearmSourceInitalized), [_source]] call CBA_fnc_globalEvent; diff --git a/docs/wiki/framework/rearm-framework.md b/docs/wiki/framework/rearm-framework.md index cd31043572..6b051f4cb6 100644 --- a/docs/wiki/framework/rearm-framework.md +++ b/docs/wiki/framework/rearm-framework.md @@ -235,3 +235,9 @@ This function sets the current supply count of the ammo truck. It can be used to ---| --------- | ----------- 0 | `ammo_truck` | My ammo truck object 1 | `1000`| Supply Count + +## 4. Events + +| Name | Arguments | Global? | Added in | +| ------------- | ------------- | ------------- | +| ace_rearm_sourceInitalized | Yes | Ammo truck (OBJECT) | 3.16.0 |