diff --git a/addons/repair/XEH_postInit.sqf b/addons/repair/XEH_postInit.sqf index 7095b0bfd0..44ca157b0c 100644 --- a/addons/repair/XEH_postInit.sqf +++ b/addons/repair/XEH_postInit.sqf @@ -5,20 +5,3 @@ // wheels ["setWheelHitPointDamage", {(_this select 0) setHitPointDamage [_this select 1, _this select 2]}] call EFUNC(common,addEventHandler); - -if (isServer) then { - ["SettingsInitialized", { - GVAR(settingInitted) = true; // Stop collecting in FUNC(addSpareParts) - - // Exit if adding spare parts disabled and clean collection - if (!GVAR(addSpareParts)) exitWith {GVAR(addSparePartsCollection) = nil}; - - // Add spare parts to vehicles in collection - { - [_x] call FUNC(addSpareParts); - } forEach GVAR(addSparePartsCollection); - - // Clean collection - GVAR(addSparePartsCollection) = nil; - }] call EFUNC(common,addEventHandler); -}; diff --git a/addons/repair/XEH_preInit.sqf b/addons/repair/XEH_preInit.sqf index c47b0b8011..f94c230f29 100644 --- a/addons/repair/XEH_preInit.sqf +++ b/addons/repair/XEH_preInit.sqf @@ -40,6 +40,4 @@ PREP(spawnObject); PREP(useItem); PREP(useItems); -GVAR(addSparePartsCollection) = []; - ADDON = true; diff --git a/addons/repair/functions/fnc_addSpareParts.sqf b/addons/repair/functions/fnc_addSpareParts.sqf index 6dfbb49bc0..4d3197c8e8 100644 --- a/addons/repair/functions/fnc_addSpareParts.sqf +++ b/addons/repair/functions/fnc_addSpareParts.sqf @@ -26,10 +26,8 @@ TRACE_2("params",_vehicle,_amount); if !(["ace_cargo"] call EFUNC(common,isModLoaded)) exitWith {}; // Collect until SettingsInitialized -if (isNil QGVAR(settingInitted)) exitWith { - if !(_vehicle in GVAR(addSparePartsCollection)) then { - GVAR(addSparePartsCollection) pushBack _vehicle; - }; +if (!EGVAR(common,settingsInitFinished)) exitWith { + EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(addSpareParts), _this]; }; // Exit if not forced and add spare parts is disabled (after settings initted to make sure it really is)