Jump to content
burdy

Help w/ AI eject script

Recommended Posts

Hey,

So currently I am trying to make a script which counts the amount of non-player units in a vehicle, and ejects them.

 

if (isserver) then {
	_veh = _this select 0;
	_unit = {!isplayer _x} forEach crew _veh;
	sleep (random 3);
	{_x addBackpack "B_parachute";} forEach (units _unit);
			{ 
			{unassignVehicle _x} forEach crew _veh;
			(_x) action ["EJECT", vehicle _veh];
			sleep 1;
                	(_x) action ["openParachute", vehicle _veh];
			} forEach (units _unit);
	
		}; 


This is what I got now - the issue is I can get the script to work without the _unit part (meaning, all units in the vehicle will disembark), however, as soon as I add that _unit part and try to keep it only AI who eject, I get a whole host of issues. 

Share this post


Link to post
Share on other sites

I'd be surprised if

_unit = {!isplayer _x} forEach crew _veh;

worked as intended. If I understand it correctly from the wiki, it would return only the last AI unit. https://community.bistudio.com/wiki/select, alternative syntax 5 should do what you want. Also, use just _unit, preferably renamed to _units, instead of (units _unit). Same thing with vehicle _veh, that's just nonsense.

Share this post


Link to post
Share on other sites
if (isserver) then {
	_veh = _this select 0;
	sleep (random 3);
	{
		if (!isPlayer _x) then {
			_x addBackpack "B_parachute";
			unassignVehicle _x;
			(_x) action ["EJECT", vehicle _veh];
			sleep 1;
			(_x) action ["openParachute", vehicle _veh];
		}
	} forEach crew _veh;
};

Will eject every AI unit even copilot, gunner, commander and pilot.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×