Jump to content
ski2060

AttachTo Item destruction

Recommended Posts

I have a friend working on a project for our unit.  He is attempting to place cargo items onto a vehicle using AttachTo to make the vehicle a bit more realistic looking, and look like it supports other functions (Ammo, Fuel supply Etc.)

The problem he is having right now is that on destruction of the parent vehicle (RHS MRZR), all of the items placed with attachTo are left behind at the location.
What scripting would he need to use in order to remove those items?

We're thinking that a script running with waitUntil looking for destruction of the vehicle, then vehicleDelete on all the items to delete them is the proper way.

Is this a correct line of thinking or should we be looking for a different script/funtion to achieve this?

Share this post


Link to post
Share on other sites
<vehicle> addEventHandler [
	'Killed',
	{
		params ['_vehicle','','',''];
		{
			deleteVehicle _x;
		} forEach (attachedObjects _vehicle);
	}
];
<vehicle> addEventHandler [
	'Deleted',
	{
		params ['_vehicle'];
		{
			deleteVehicle _x;
		} forEach (attachedObjects _vehicle);
	}
];

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers

  • Like 1

Share this post


Link to post
Share on other sites

If this is for use in MP Zeus missions, would the MPKilled and addMPEventHandler be used instead?

Share this post


Link to post
Share on other sites

The "killed" EH needs to activated where local, so maybe do fn_Quiksilvers code in the initline with "this", or yes use MPKilled and make sure you only run it once there.  Obv check for yourself though as the proof is in the pudding.

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

×