Jump to content
Sign in to follow this  
bullet purveyor

Req. Remove floating sandbags from destroyed buildings.

Recommended Posts

Is there a script out there that can detect when a building gets destroyed and remove editor placed objects from that building?

I'm mainly thinking of sandbag fortifications here, as they stay floating in the air after the building is collapsed.

Share this post


Link to post
Share on other sites

If you placed the building down yourself you give it a name, let's say "building1" (without the quotation marks). You also give the sandbags names: sandbag1, sandbag2, etc. Then you make a trigger. In the condition you put "!alive building1". In the activation field you put "deletevehicle sandbag1; deletevehicle sandbag2;" etc.

If the building is part of the map you could try grouping it with the trigger and putting "!alive this" in the condition. I don't know if that works though.

Share this post


Link to post
Share on other sites

It's a building I placed down myself in the editor, or rather multiple buildings in a camp with many sandbags. So I was hoping more of a trigger that could remove all objects of same type, something simple like 'remove class sandbags' or similar. :)

I will try your suggestion though, thanks for the help.

EDIT: that worked great, thanks again.

Will this work in MP?

EDIT2: I tested "!alive this" on an existing building, part of the map. I then get error: '!|#|alive this' Error alive: Type Bool, expected object

Edited by Bullet Purveyor

Share this post


Link to post
Share on other sites

I would suggest you to use the Killed EH:

if((isServer) or (isDedicated)) then {
_myBuildingNameArray = [building1,building2]; //can be expanded with anything

{
	_myKilledEH = _x addEventHandler ["Killed", {
		_building = _this select 0;
		_buildingPos = getPosATL _building;

		_sandBags = nearestObjects [_buildingPos, ["BagFence_base_F"], 30]; // you can also add other classnames but BagFence_base_F should cover all sandbags, distance around house 30m (can be tweaked with the number)
		{
			deleteVehicle _x;
		}forEach _sandBags
	}];

}forEach _myBuildingNameArray;
};

It is untested but i think you get what i mean.

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
Sign in to follow this  

×