---
name: "BIS_fnc_randomPos"
type: function
status: ok
groups: ["Positions"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/BIS_fnc_randomPos
revid: 349485
updated: 2023-11-08T17:09:03Z
---

# BIS_fnc_randomPos

*Function · Positions · Arma 3 v0.50 · introduced in Take On Helicopters v1.00*

## Description

Selects random position according to given params within given area

## Syntax

```sqf
[whitelist, blacklist, code] call BIS_fnc_randomPos
```

**Parameters:**

- `whitelist`: [Array](../topics/Array.md) - whitelisted areas. If not given, whole map is used. Areas can be:
  - [Object](../topics/Object.md) - trigger
  - [String](../topics/String.md) - marker
  - [Array](../topics/Array.md) - in format [center, radius] or [center, [a, b, angle, rect]]
  - [Location](../topics/Location.md) - location
- `blacklist`: [Array](../topics/Array.md) - (Optional, default `[]`) blacklisted areas. If not given, water is blacklisted. Areas can be:
  - [Object](../topics/Object.md) - trigger
  - [String](../topics/String.md) - marker name or special tags names: "water" - exclude water, "ground" - exclude land
  - [Array](../topics/Array.md) - in format [center, radius] or [center, [a, b, angle, rect]]
  - [Location](../topics/Location.md) - location
- `code`: [Code](../topics/Code.md) - (Optional, default `{ true }`) custom condition which should return true for current position candidate passed in [_this](../topics/Magic_Variables.md#this) variable to be accepted. If not specified all candidates are accepted

**Returns:** [Array](../topics/Array.md) - position candidate in format [x,y,z] or [0,0] if position cannot be found

## Examples

### Example 1

```sqf
private _randomPosMapNoWater = [] call BIS_fnc_randomPos;
```

### Example 2

```sqf
private _randomPosMapNoWater = [nil, ["water"]] call BIS_fnc_randomPos;
```

### Example 3

```sqf
private _randomPosMapNoLand = [nil, ["ground"]] call BIS_fnc_randomPos;
```

### Example 4

```sqf
private _randomPosMap = [nil, []] call BIS_fnc_randomPos;
```

### Example 5

```sqf
private _randomPosAroundPlayer = [[[position player, 50]], []] call BIS_fnc_randomPos;
```

## See also

[BIS_fnc_randomPosTrigger](../functions/BIS_fnc_randomPosTrigger.md) · [BIS_fnc_getArea](../functions/BIS_fnc_getArea.md) · [BIS_fnc_findSafePos](../functions/BIS_fnc_findSafePos.md)

## Community notes

**Tankbuster** — 2020-03-30

The code parameter here can be quite powerful.
If using [#Example 5](../functions/BIS_fnc_randomPos.md#example-5) above, adding code as below will make the returned positions always be on a road.

```sqf
private _randomRoadPosAroundPlayer = [[[position player, 50]], [], { isOnRoad _this }] call BIS_fnc_randomPos;
```

<sub>Source: [BI Community Wiki — BIS fnc randomPos](https://community.bistudio.com/wiki/BIS_fnc_randomPos) (revision 349485).</sub>
