---
name: "selectMax"
type: command
status: ok
groups: ["Arrays"]
arma3_since: "1.66"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/selectMax
revid: 379373
updated: 2026-10-30T23:57:52Z
---

# selectMax

*Command · Arrays · Arma 3 v1.66*

## Description

Returns the array element with [maximum](../commands/max.md) numerical value. Engine solution to [BIS_fnc_greatestNum](../functions/BIS_fnc_greatestNum.md) and [BIS_fnc_findExtreme](../functions/BIS_fnc_findExtreme.md). Therefore it is expected that supplied array consists of [Numbers](../topics/Number.md) only. [Booleans](../topics/Boolean.md) however are also supported and will be evaluated as [Numbers](../topics/Number.md): [true](../commands/true.md) - 1, [false](../commands/false.md) - 0. [nil](../commands/nil.md) value treated as 0.

> [!WARNING]
> Other non [Number](../topics/Number.md) elements (not recommended) will be evaluated as 0 and **Bad conversion: scalar** message will be logged into .[rpt](../topics/Crash_Files.md).

## Syntax

```sqf
selectMax array
```

**Parameters:**

- `array`: [Array](../topics/Array.md) of [Numbers](../topics/Number.md)

**Returns:** [Number](../topics/Number.md) - element with [maximum](../commands/max.md) numerical value

## Examples

### Example 1

```sqf
_max = selectMax [1,2,3,4,5]; //5
```

### Example 2

```sqf
// Same as, for example:
_max = _a max _b max _c max _d;
// Only faster:
_max = selectMax [_a,_b,_c,_d];
```

## See also

[selectMin](../commands/selectMin.md) · [min](../commands/min.md) · [max](../commands/max.md) · [selectRandom](../commands/selectRandom.md) · [select](../commands/select.md) · [selectRandomWeighted](../commands/selectRandomWeighted.md)

## Community notes

**Longbow** — 2016-12-19

Returns either number or boolean value, in case max value in array 0, command will return either 0 or false, which ever comes first.
Same for 1 and true values.

```sqf
selectMax [false,0] // returns false
selectMax [0,false] // returns 0
selectMax [true,1] // returns true
selectMax [1,true] // returns 1
```

in case all values are equal or less than zero, command may also return other type of values

```sqf
selectMax ["",false,0,-1] // returns ""
```

if nil value appears in array, other values are equal or less than zero, command returns nil

<sub>Source: [BI Community Wiki — selectMax](https://community.bistudio.com/wiki/selectMax) (revision 379373).</sub>
