Jump to content
Sign in to follow this  
jakkob4682

how to get an array of all AIRPORTS using nearestLocation and Fnc_locations?

Recommended Posts

Basically what the title says. I've tried _airports = nearestLocation [getPos player,["Airport"],20000]; and then I try to select one using _airports select 0 but it says type number expected string in the rpt log

Share this post


Link to post
Share on other sites

First, what map are you using this code on? The BIS maps and IceBreakers maps all use map locations, but other custom maps are hit and miss, these must be defined in the map.(They can be created on the fly, but its a lot of work if your creating a lot.).

Second please post your code so we can see that you are selecting and using the location properly.

Share this post


Link to post
Share on other sites
First, what map are you using this code on? The BIS maps and IceBreakers maps all use map locations, but other custom maps are hit and miss, these must be defined in the map.(They can be created on the fly, but its a lot of work if your creating a lot.).

Second please post your code so we can see that you are selecting and using the location properly.

I looked at the locations cfg for Takistan and found there are no actual airports its listed under "NameLocal" but there are a few locations with that type so how would I go about using the actual name of the location in the config? I have

waitUntil {(taskCompleted tsk1 && taskCompleted tsk2)};
locations = nearestLocations [getPos hitman,["NameLocal"],25000];
airports = [];
{
	if ((name _x == "AIRFIELD")||(name _x == "Military Base")) then {
		airport = airport + [_x];
		};
}forEach locations;
airport = airports select 0;
apmarker = createMarker ["ap",position airport];
"ap" setMarkerType "Ellipse";
"ap" setMarkerColor "ColorRed";
"ap" setMarkerText "Operations_HQ";
"ap" setMarkerSize [20,20];
"ap" setMarkerBrush "Border";
transport = [getMarkerPos "ap",360,"UH1Y",group hitman] call BIS_fnc_spawnVehicle;
evac = "HeliH" createVehicle getPos hitman;
transport doMove getPos evac;
waitUntil {(transport distance evac < 10)};
	transport land "Get In";
waitUntil {(hitman in transport)};
	evac setPos getMarkerPos "ap";
	sleep 5;
	transport doMove getPos evac;
waitUntil {(transport distance evac < 10)};
	transport land "land";

but the marker never gets created and it spawns the huey at the bottom corner of the screen which if it didn't have a RTB function would be all right but it doesn't :(

Error in expression <Move getPos evac;

waitUntil {(transport distance evac < 10)};

transport land "Ge>

Error position: <distance evac < 10)};

transport land "Ge>

Error Type Object, expected Number

Edited by jakkob4682
added rpt error

Share this post


Link to post
Share on other sites

You need to read from the cfg the ilsposition and the secondary airports...This of course if the airports are created correctly on the map you're using. You can add your own positions, like Mando does if needed.

Here is small example from HOZ, he made a function to find nearest airport(I'm sure others have also)...

	_cfgILSD = [];
_cfgName = "";
_cfgAirP =(configFile >> "cfgWorlds" >> worldName );
_cfgILSP = getArray (_cfgAirP  >> "ilsPosition");
_cfgILSD = getArray (_cfgAirP  >> "ilsDirection");
_cfgName = [_cfgILSP, 2000] call ClosestTown;
_AirportArray set [0, [format["%1",_cfgName select 0], _cfgILSP, _cfgILSD]];
_cfgAirP =(configFile >> "cfgWorlds" >> WorldName >> "SecondaryAirports");
for "_i" from 0 to ((Count _cfgAirP)-1) do
{
	_k = _i +1;
   _cfgILSP = getArray (_cfgAirP Select _i >> "ilsPosition");
   _cfgILSD = getArray (_cfgAirP Select _i >> "ilsDirection");
   _cfgName = [_cfgILSP, 2000] call ClosestTown;
   _distP = _cfgName select 0;
  //if (_cfgName select 0 == "") then {_cfgName select 0 = ["Remote"];};
 //  _AirportArray set [_k,[format["%1",(_cfgName select 0)], _cfgILSP, _cfgILSD]]; 
	 _AirportArray set [_k,[format["%1",(_cfgName select 0)], _cfgILSP, _cfgILSD]]; 
};
player sidechat format ["%1", _AirportArray];
_nAport = count _AirportArray;

again, this is just part of that function, but will give you an idea what I'm talking about

Share this post


Link to post
Share on other sites

its also giving me this error

rror in expression <

apmarker = createMarker ["ap",position airport];

"ap" setMarkerType "Ellipse";

>

Error position: <airport];

"ap" setMarkerType "Ellipse";

>

Error Undefined variable in expression: airport

---------- Post added at 14:30 ---------- Previous post was at 14:28 ----------

ah so I can't use the name _x command on the locations array, thanks was hoping I wouldn't have to get into the configFile thing but looks that way. Thanks for the help

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  

×