OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: hoz on 21 Aug 2007, 05:38:44
-
// This function will locate the nearest airport and display it back to you.
// You can check for the nearest Airport within a specified distance as well.
Usage:
// Add this to compile the function in your init.sqf
ClosestAirport = compile (preprocessFileLineNumbers "findnearestairport.sqf");
// Use this to call the function
_Aportinfo = [player, 9000] call ClosestAirport;
Return:
%1 - Name of the town
%2 - Distance in Meter
%3 - Direction heading (north, south, etc)
Example of the return:
hint format ["The Closest Town is: %1, \n%2m to the %3",_Aportinfo select 0,_Aportinfo select 2, _Aportinfo select 1];
Edit:
Updated to return the closest town name as the airport name within 2KM.
If no town is around, the name is automatically called 'Remote', as in Remote Airstrip.
Meters is now rounded to KM.
Now should work on any island. :)
Let me know if there are any bugs.
-
Good work :good:
You may try add the following:
1 - _distance_to_airport = _distance_to_airport - _distance_to_airport % 1 to get rid of the decimals when returning the range, a range in Km with 1 decimal would be good too.
2 - Include also your function to find nearest town so, if a town is closer than 1000m from the airport you return the name of the town instead of just AirStrip#, for example "Paraiso airport, 8.4Km to the West".
-
I'm working on the second part already, I didn't know about the decimal I'll have a peek at that as well.
New file attached, hopefully it will be final. thanks for the suggestions.
-
The function has been accepted and moved into ED Depot ArmA functions