Jump to content
Beowulfv

Object distance to player

Recommended Posts

I am trying to setup a check for when the player is within a certain distance from an array of objects. I can't figure out why I'm not getting the distance of the array objects to test against the first condition. The system will just jump straight to the else statement due to this. Example code below:
 

_AllowedShips = getArray (missionConfigFile >> "CfgBuilding" >> "Ships" >> "AllowedShips");


if (_AllowedShips distance (getPosASL player) < 50) then
    {
		if ((getPosASL ExileClientConstructionObject) select 2 > _SeaLevel) then {
			ExileClientConstructionModePhysx = true;
			ExileClientConstructionResult = 2;
			["ErrorTitleAndText", [_MaxBuildHeightErrMsgTiltle, _MaxBuildHeightErrMsgContent]] call ExileClient_gui_toaster_addTemplateToast;
		}
	}else{
		if ((getPosATL ExileClientConstructionObject) select 2 > _MaxBuildHeight) then {
			ExileClientConstructionModePhysx = true;
			ExileClientConstructionResult = 2;
			["ErrorTitleAndText", [_MaxBuildHeightErrMsgTiltle, _MaxBuildHeightErrMsgContent]] call ExileClient_gui_toaster_addTemplateToast;
		}
	};

The array is listed as:
 

class CfgBuilding
{
	class Ships {
		AllowedShips[] = {
			"Land_Carrier_01_base_F",
			"Land_Destroyer_01_base_F"
		};
	};
}; 

Yes the modification is for Exile mod, but the fundamentals for what I am trying to do is vanilla Arma. I have found one post similar to what I am trying to do, but they are only testing for a radio tower and not an array. For the most part what was suggested to them is similar to what I have done. If anyone has a better understanding of working with distance please shed some light on this for me.

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

×