DanJohn 3 Posted March 3, 2019 I have created a Virtual Vehicle Spawner But I want the old vehicle to delete once the new vehicle has been spawned. Right now i can spawn however much vehicles i want. I have tried to add in my own check but it doesnt work. If i change (count Old_Vehicles_Spawned > 1) to (count Old_Vehicles_Spawned > 0) i am able to spawn in a vehicle that deletes straight away so im not sure why (count Old_Vehicles_Spawned > 1). Any help would be appreciated. Code: Spoiler Old_Vehicles_Spawned = []; _VehicleSelected = lbCurSel 1; _classVeh = lbData[1, _VehicleSelected]; _emptyPos = position player findEmptyPosition [5,50, _classVeh]; //Spawn A Vehicle 5-50M around player if (count _emptyPosDir == 0) exitWith {hint "Vehicle Cant be Spawned Here"; }; _veh = createVehicle [_classVeh, _emptyPos, [], 0, ""]; _veh setDir (getDir player); _veh setVehicleAmmo 0; _veh setVehicleAmmoDef 0; clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; clearBackpackCargoGlobal _veh; player moveInAny _veh; //if (_Old_Vehicle_Spawned isEqualTo "") exitWith {closeDialog 18002;} Old_Vehicles_Spawned pushBack _veh; if (count Old_Vehicles_Spawned > 1) then { deleteVehicle (Old_Vehicles_Spawned select 0); [Old_Vehicles_Spawned] call BIS_fnc_arrayShift; }; closeDialog 18002; Share this post Link to post Share on other sites
DanJohn 3 Posted March 3, 2019 I only just realized this after trying to figure out the problem for the last week that every time the function was called I was resetting the array by adding this to the top Old_Vehicles_Spawned = []; Share this post Link to post Share on other sites
HazJ 1288 Posted March 3, 2019 if (isNil "Old_Vehicles_Spawned") then { Old_Vehicles_Spawned = []; }; This will only define it if it doesn't exist in first place. 1 Share this post Link to post Share on other sites