Jump to content
takeMS

forbid a player to place mines

Recommended Posts

how to forbid a player to place mines such as:ATMine,APERS near object example houses or fuel stantion?

Share this post


Link to post
Share on other sites

Start by creating an action handler that will disable the mine placement action. Here's an example:

inGameUISetEventHandler ["Action", "
	if (_this select 3 == 'DisAssemble') then
	{
		hint 'You are not allowed to do this';
		true
	}
"];

Then turn on the processing of this handler only if the player is close to a building or gas station.

  • Like 1

Share this post


Link to post
Share on other sites

This code in the player's init will disable the use of mines by the player near any building (if the player is within the boundingbox of that building)

inGameUISetEventHandler ["Action", 
"  
	if (
		(_this select 3 == 'UseMagazine')
		&&
		(call 
			{
				_near = false;
				_all_buildings = nearestObjects [player, ['house','building'], 50];
				
				if (count _all_buildings == 0) exitWith {_near};
				
					{
						_box = boundingBox _x;
						
						_hypotenuse1 = sqrt (( abs ((_box select 0 select 0)^2))+( abs ((_box select 0 select 1)^2)));
						_hypotenuse2 = sqrt ((( _box select 1 select 0)^2)+( (_box select 1 select 1)^2));					
						
						_hypotenuse = selectMax [_hypotenuse1, _hypotenuse2];
						
						if (player distance2d position _x < _hypotenuse) exitWith 
							{
								_near = true;
							};
					} forEach _all_buildings;
				_near;
			}
		)
		
		) then 
		 { 
			  true 
		 } 
"
];

 

  • 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

×