Jump to content
redarmy

Force AI group out of player vehicle

Recommended Posts

Im trying to set up a mission where the player has an add action or a trigger to tell loaded AI groups to leave his helicopter. I need it so that the passengers and only the passengers leave the helo preferably on a add action that the player who is the pilot can use whenever he wants.

 

I tested with unnasign vehicle in many ways but nothing is working.

 

How would i accomplish this? It seems easily doable but being away from Arma3 for nearly 2 years my scripting knowledge is awful.

 

EDIT

 

I would prefer not to have the AI group have a name as the player will be picking up ranomly spawned groups throughout the mission.So a specific group name to exit specific vehicle name,isnt useful to me.

Share this post


Link to post
Share on other sites

This should get you started.
Not tested!

player addAction
[
	"GTFO!",
	{
		{
			moveOut _x;
			unassignVehicle _x;
		} forEach (fullCrew [vehicle player, "cargo"]);
	}
];

 

Share this post


Link to post
Share on other sites
11 hours ago, Maff said:

This should get you started.
Not tested!


player addAction 
[ 
 "GTFO!", 
 { 
  { 
   moveOut _x; 
   unassignVehicle _x; 
  } foreach assignedCargo (vehicle player); 
 } 
];

Thanks,but when i place this into the players init and use the add action it doesnt work and im shown the following error message:

 

error moveout :type array expected object

 

Share this post


Link to post
Share on other sites

OK After alot of testing with other variations i found this to work well

 

player addAction 
[ 
 "GTFO!", 
 { 
  { 
   moveOut _x; 
   unassignVehicle _x; 
  } foreach assignedCargo (vehicle player); 
 } 
];

I have a further issue though,it seems the hummingbird rails are counting as crew member positions and not passenger positions so AI sat on the rails are not ejecting

Share this post


Link to post
Share on other sites

Hey man, have you found a solution already?
I think you just need to change the second parameter of the forEach.
Try this:

forEach ((crew vehicle player) select {!isPlayer _x})

This should eject every AI that's in your vehicle.

 

Share this post


Link to post
Share on other sites
3 hours ago, iSassafras said:

Hey man, have you found a solution already?
I think you just need to change the second parameter of the forEach.
Try this:


forEach ((crew vehicle player) select {!isPlayer _x})

This should eject every AI that's in your vehicle.

 

Hey i hadnt found  a way yet.This does work but it also ejects co pilots and gunners. I tried to replace "crew",with "Cargo" and "passengers" but its throwing up errors.

Share this post


Link to post
Share on other sites

I see. Sorry, I missed that you wanted to keep these inside your vehicle.
There aren't any commands called "cargo" or "passengers" as far as I know, so that's probably why it's throwing up errors.

In this case I'd suggest you find out which assigned roles of your vehicle you don't wish to empty. You could assume that the copilot is the vehicle commander and both door gunners are assigned as gunner, but out of my experience this is not always the case, so you better find it out manually using assignedVehicleRole.

I'd just start a mission and get into the role of your heli which you don't want to empty, e.g. the pilot. Then you can type "assignedVehicleRole player" into your admin console. This should return  ["Driver"] when you're the pilot. Save the return somewhere, e.g. in a text file on your desktop. Repeat this step for all the vehicle roles you don't want to empty.

Then you'll have to filter the array which you're running the forEach for a bit further, e.g.:

forEach ((crew vehicle player) select {(!isPlayer _x) and !(assignedVehicleRole _x isEqualTo ["Driver"])})

You'll have to add the "and !(assignedVehicleRole ..." phrase for every vehicle role you have saved in your text file and replace the ["Driver"] accordingly. Keep in mind that this will possibly only work correctly for this one specific type of vehicle.
It's a bit of a dirty method but it should do the trick.

Share this post


Link to post
Share on other sites
On 12/6/2020 at 12:50 AM, iSassafras said:

I see. Sorry, I missed that you wanted to keep these inside your vehicle.
There aren't any commands called "cargo" or "passengers" as far as I know, so that's probably why it's throwing up errors.

In this case I'd suggest you find out which assigned roles of your vehicle you don't wish to empty. You could assume that the copilot is the vehicle commander and both door gunners are assigned as gunner, but out of my experience this is not always the case, so you better find it out manually using assignedVehicleRole.

I'd just start a mission and get into the role of your heli which you don't want to empty, e.g. the pilot. Then you can type "assignedVehicleRole player" into your admin console. This should return  ["Driver"] when you're the pilot. Save the return somewhere, e.g. in a text file on your desktop. Repeat this step for all the vehicle roles you don't want to empty.

Then you'll have to filter the array which you're running the forEach for a bit further, e.g.:


forEach ((crew vehicle player) select {(!isPlayer _x) and !(assignedVehicleRole _x isEqualTo ["Driver"])})

You'll have to add the "and !(assignedVehicleRole ..." phrase for every vehicle role you have saved in your text file and replace the ["Driver"] accordingly. Keep in mind that this will possibly only work correctly for this one specific type of vehicle.
It's a bit of a dirty method but it should do the trick.

Awesome i will check this way out ASAP. Thanks mate

  • Like 1

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

×