Arma 3 Scripting

Command in Locations

nearestLocations

Also available as Markdown and JSON, or read the original wiki page.

Description

Returns an array of locations of chosen type(s) within the given radius of the given position, sorted from nearest to farthest.

Note

Although locations can be placed in 3D with setPosition, nearestLocations' search result is sorted in 2D.

Syntax

nearestLocations [centre, locationTypes, radius, sortPosition]

Parameters:

Returns: Array of Locations

Examples

Example 1

_nearbyLocations = nearestLocations [getPosATL player, ["RockArea", "VegetationFir"], 100];

Example 2

Find any of nearest locations:

private _allLocationTypes = [];
"_allLocationTypes pushBack configName _x" configClasses (configFile >> "CfgLocationTypes");
{
    systemChat format [
        "%1 (%2) - %3m", 
        _x, 
        text _x, 
        getPosATL player distance _x
    ];
} forEach nearestLocations [player, _allLocationTypes, 500];

See also

createLocation · nearestLocation · locationPosition · nearestLocationWithDubbing