Home   Help Search Login Register  

Author Topic: FindNearestAirport (ACCEPTED)  (Read 2261 times)

0 Members and 1 Guest are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
FindNearestAirport (ACCEPTED)
« 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.
« Last Edit: 01 Sep 2007, 15:31:51 by Mandoble »
Xbox Rocks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: FindNearestAirport
« Reply #1 on: 21 Aug 2007, 13:51:36 »
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".

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: FindNearestAirport
« Reply #2 on: 21 Aug 2007, 15:25:05 »
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.
« Last Edit: 22 Aug 2007, 22:27:15 by hoz »
Xbox Rocks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: FindNearestAirport (ACEPTED)
« Reply #3 on: 01 Sep 2007, 15:23:37 »
The function has been accepted and moved into ED Depot ArmA functions