Cleaned up spare parts collection after SettingsInitialized, Check if vehicle already in collection

This commit is contained in:
jonpas 2015-08-26 23:43:06 +02:00
parent 48e0f5757d
commit 6d27299883
2 changed files with 7 additions and 2 deletions

View File

@ -10,12 +10,15 @@ if (isServer) then {
["SettingsInitialized", {
GVAR(settingInitted) = true; // Stop collecting in FUNC(addSpareParts)
// Exit if adding spare parts disabled
// 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

@ -27,7 +27,9 @@ if !(["ace_cargo"] call EFUNC(common,isModLoaded)) exitWith {};
// Collect until SettingsInitialized
if (isNil QGVAR(settingInitted)) exitWith {
GVAR(addSparePartsCollection) pushBack _vehicle;
if !(_vehicle in GVAR(addSparePartsCollection)) then {
GVAR(addSparePartsCollection) pushBack _vehicle;
};
};
// Exit if not forced and add spare parts is disabled (after settings initted to make sure it really is)