diff --git a/addons/refuel/functions/fnc_initSource.sqf b/addons/refuel/functions/fnc_initSource.sqf index 38c6c612f95..c484c151f48 100644 --- a/addons/refuel/functions/fnc_initSource.sqf +++ b/addons/refuel/functions/fnc_initSource.sqf @@ -15,14 +15,12 @@ * Public: No */ +if (!hasInterface) exitWith {}; + params ["_source"]; TRACE_2("init",_source,typeOf _source); -if (hasInterface) then { - [_source, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject); - { - [_source, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToObject); - } forEach GVAR(actions); -}; - -[QGVAR(fuelSourceInitialized), [_source]] call CBA_fnc_localEvent; +[_source, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject); +{ + [_source, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToObject); +} forEach GVAR(actions); diff --git a/addons/refuel/functions/fnc_makeJerryCan.sqf b/addons/refuel/functions/fnc_makeJerryCan.sqf index c33c09960fe..b81aa8e234c 100644 --- a/addons/refuel/functions/fnc_makeJerryCan.sqf +++ b/addons/refuel/functions/fnc_makeJerryCan.sqf @@ -27,7 +27,7 @@ _target setVariable [QGVAR(source), _target]; _target setVariable [QGVAR(capacity), _fuelAmount]; if (isServer) then { - [_target, _fuelAmount] call FUNC(setFuel); // has global effects + [_target, _fuelAmount] call FUNC(setFuel); // has global effects [QVAR(jerryCanInitalized), [_target]] call CBA_fnc_globalevent; }; diff --git a/addons/refuel/functions/fnc_makeSource.sqf b/addons/refuel/functions/fnc_makeSource.sqf index 823b1526435..060d7177f58 100644 --- a/addons/refuel/functions/fnc_makeSource.sqf +++ b/addons/refuel/functions/fnc_makeSource.sqf @@ -56,9 +56,11 @@ if ( _source setVariable [QGVAR(hooks), _hooks, true]; }; -// check if menu already exists -if (_fuelCargoConfig != 0 || {!isNil {_source getVariable QGVAR(initSource_jipID)}}) exitWith {}; +// only add if menu doesn't already exist +if (!(_fuelCargoConfig != 0 && {!isNil {_source getVariable QGVAR(initSource_jipID)}})) then { + private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP; + [_jipID, _source] call CBA_fnc_removeGlobalEventJIP; + _source setVariable [QGVAR(initSource_jipID), _jipID]; +}; -private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP; -[_jipID, _source] call CBA_fnc_removeGlobalEventJIP; -_source setVariable [QGVAR(initSource_jipID), _jipID]; +[QGVAR(sourceInitialized), [_source]] call CBA_fnc_globalEvent; diff --git a/docs/wiki/framework/refuel-framework.md b/docs/wiki/framework/refuel-framework.md index 73a2ca08d60..6460ee2e765 100644 --- a/docs/wiki/framework/refuel-framework.md +++ b/docs/wiki/framework/refuel-framework.md @@ -130,5 +130,5 @@ The jerry can will now have a volume of 200 liters. | Name | Arguments | Global? | Added in | | ------------- | ------------- | ------------- | -| ace_refuel_fuelSourceInitialized | Fuel source (OBJECT), items (BOOL or ARRAY) | No | 3.16.0 | +| ace_refuel_sourceInitialized | Fuel source (OBJECT), items (BOOL or ARRAY) | Yes | 3.16.0 | | ace_refuel_jerryCanInitalized | Jerry can (OBJECT) | Yes | 3.16.0 |