Mokey II 5 Posted May 13, 2018 So currently I am working on an A3W script for my server, I'm attempting to spawn crates to parachutes so the fall from the sky. I have the functionality working. But I can't seem to get it to spawn the crates on the last vehicle alive in the array. If a player kills the last chopper in the array it spawns the crate on the chopper defined. How do I pass multiple params and define the condition for the last chopper alive to spawn crates on? The successExex starts AFTER the last vehicle is destroyed. _vehicles = [ [_veh1, _missionPos vectorAdd ([[random 50, 0, 0], random 360] call BIS_fnc_rotateVector2D), 0] call _createVehicle, [_veh2, _missionPos vectorAdd ([[random 50, 0, 0], random 360] call BIS_fnc_rotateVector2D), 0] call _createVehicle, [_veh3, _missionPos vectorAdd ([[random 50, 0, 0], random 360] call BIS_fnc_rotateVector2D), 0] call _createVehicle ]; _successExec = { _numCratesToSpawn = 3; _i = 0; while {_i < _numCratesToSpawn} do { _vehicles spawn { params ["_veh1", "_veh2", "veh3"]; // HERE IS MY ISSUE, BUT CAN'T FIGURE OUT HOW TO CHECK CONDITION FOR LAST ALIVE VEHICLE _crate = createVehicle ["Box_East_Wps_F", (getPosATL _veh1) vectorAdd ([[_veh1 call fn_vehSafeDistance, 0, 0], random 360] call BIS_fnc_rotateVector2D), [], 5, "None"]; _crate setDir random 360; _crate allowDamage false; waitUntil {!isNull _crate}; _crateParachute = createVehicle ["O_Parachute_02_F", (getPosATL _crate), [], 0, "CAN_COLLIDE" ]; _crateParachute allowDamage false; _crate attachTo [_crateParachute, [0,0,0]]; _crate call randomCrateLoadOut; waitUntil {getPosATL _crate select 2 < 5}; detach _crate; deleteVehicle _crateParachute; _smokeSignal = createVehicle ["SmokeShellRed", getPosATL _crate, [], 0, "CAN_COLLIDE" ]; _lightSignal = createVehicle ["Chemlight_red", getPosATL _crate, [], 0, "CAN_COLLIDE" ]; _smokeSignal attachTo [_crate, [0,0,0.2]]; _lightSignal attachTo [_crate, [0,1,0]]; _crate allowDamage true; }; _i = _i + 1; }; _successHintMessage = "The sky is clear again, the enemy patrol was taken out! Ammo crates have fallen out their chopper."; }; Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted May 13, 2018 To check if an array only contains a single alive unit you can do this: waitUntil {count (_vehicles select {alive _x}) isEqualTo 1}; _lastAlive = _vehicles select {alive _x} select 0; Cheers 1 Share this post Link to post Share on other sites
Mokey II 5 Posted May 13, 2018 I saw your post from a while ago, and couldn't get it to work properly. I guess I'm not understanding where or how to pass this exactly @Grumpy Old Man. It states there is an undefined variable for _vehicles. if called outside of the _successExec Scope. But it is clearly defined as the create vehicle array. If Called within the _successExec scope, it only creates 1 vehicle.and breaks the script. Script in my mission file: https://github.com/Fractured-Gaming-Official/Frac_v1.4.Stratis/blob/master/server/missions/mainMissions/mission_HostileHeliFormation.sqf Correction: It spawned all 3 chopppers, but it didn't continue with the crates: _successExec = { waitUntil {count (_vehicles select {alive _x}) isEqualTo 1}; _lastAlive = _vehicles select {alive _x} select 0; _numCratesToSpawn = 3; _i = 0; while {_i < _numCratesToSpawn} do { _vehicles spawn { params ["_lastAlive"]; _crate = createVehicle ["Box_East_Wps_F", (getPosATL _lastAlive) vectorAdd ([[_lastAlive call fn_vehSafeDistance, 0, 0], random 360] call BIS_fnc_rotateVector2D), [], 5, "None"]; _crate setDir random 360; _crate allowDamage false; waitUntil {!isNull _crate}; _crateParachute = createVehicle ["O_Parachute_02_F", (getPosATL _crate), [], 0, "CAN_COLLIDE" ]; _crateParachute allowDamage false; _crate attachTo [_crateParachute, [0,0,0]]; _crate call randomCrateLoadOut; waitUntil {getPosATL _crate select 2 < 5}; detach _crate; deleteVehicle _crateParachute; _smokeSignal = createVehicle ["SmokeShellRed", getPosATL _crate, [], 0, "CAN_COLLIDE" ]; _lightSignal = createVehicle ["Chemlight_red", getPosATL _crate, [], 0, "CAN_COLLIDE" ]; _smokeSignal attachTo [_crate, [0,0,0.2]]; _lightSignal attachTo [_crate, [0,1,0]]; _crate allowDamage true; }; _i = _i + 1; }; _successHintMessage = "The sky is clear again, the enemy patrol was taken out! Ammo crates have fallen out their chopper."; }; Share this post Link to post Share on other sites
Mokey II 5 Posted May 13, 2018 Now that I'm really looking at it, it seems it's stuck at the waitUntil statement. It think this is due to A3W code. It can't find the last alive vehicle if it's already succeeded. (successExec), so how do find the last alive prior successExec? A3W Forums are down btw, hence why I am asking you :P Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted May 14, 2018 15 hours ago, Mokey II said: Now that I'm really looking at it, it seems it's stuck at the waitUntil statement. It think this is due to A3W code. It can't find the last alive vehicle if it's already succeeded. (successExec), so how do find the last alive prior successExec? A3W Forums are down btw, hence why I am asking you :P _vehicles doesn't exist inside _successExec, since it's a separate scope. You can either pass on _vehicles as parameter into _successExec or make it global. Cheers Share this post Link to post Share on other sites
Mokey II 5 Posted May 16, 2018 Thanks, got it working :) it was indeed passed elswere. 1 Share this post Link to post Share on other sites