Use setting init delay function for addSpareParts

This commit is contained in:
jonpas 2015-09-05 19:33:25 +02:00
parent 41db78b52b
commit a8412361bd
3 changed files with 2 additions and 23 deletions

View File

@ -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);
};

View File

@ -40,6 +40,4 @@ PREP(spawnObject);
PREP(useItem);
PREP(useItems);
GVAR(addSparePartsCollection) = [];
ADDON = true;

View File

@ -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)