---
name: "params"
type: command
status: ok
groups: ["Variables", "Arrays"]
arma3_since: "1.48"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/params
revid: 377705
updated: 2026-01-02T09:03:38Z
---

# params

*Command · Variables, Arrays · Arma 3 v1.48*

## Description

Parses input argument into array of [private](../commands/private.md) variables. When used without argument, as shown in main syntax, internal variable [_this](../topics/Magic_Variables.md#this), which is usually available inside functions and event handlers, is used as argument.

In addition to simple parsing directly into variables, input can be tested in case it is undefined, of the wrong type or of the wrong size (if array) and substituted if necessary with default values. Since Arma 3 v1.54, onscreen errors are displayed for when the input is of the wrong type or size.

> [!WARNING]
> All variables names must start with underscore and be enclosed in quotes:

> [!NOTE]
> It is a good practice to make your local variables **private** (through [private](../commands/private.md) or [params](../commands/params.md)) in order to avoid overwriting a local variable of the same name.

## Syntax

### Syntax 1

```sqf
params [element1, element2, ...]
```

**Parameters:**

- `elementN`: [String](../topics/String.md) or [Array](../topics/Array.md)
  - [String](../topics/String.md):name of the [private](../commands/private.md) variable (must begin with underscore _, e.g. "_myVar", or can be an empty string "", in which case the element is skipped)
  - [Array](../topics/Array.md) with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]
    - variableName: [String](../topics/String.md) - name of a [private](../commands/private.md) variable (must begin with underscore _, e.g. "_myVar")
    - defaultValue: [Anything](../topics/Anything.md) - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).
    - expectedDataTypes: [Array](../topics/Array.md) of direct Data Types - (Optional) checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.
    - expectedArrayCount: [Number](../topics/Number.md) or [Array](../topics/Array.md) - (Optional) a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.

**Returns:** [Boolean](../topics/Boolean.md) - [false](../commands/false.md) if error occurred or default value has been used, otherwise [true](../commands/true.md)

### Syntax 2

```sqf
argument params [element1, element2, ...]
```

**Parameters:**

- `argument`: [Anything](../topics/Anything.md) - a usual array of params is expected. If a non-array argument is passed, it will be converted to 1 element array
- `elementN`: [String](../topics/String.md) or [Array](../topics/Array.md)
  - [String](../topics/String.md):name of the [private](../commands/private.md) variable (must begin with underscore _, e.g. "_myVar", or can be an empty string "", in which case the element is skipped)
  - [Array](../topics/Array.md) with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]
    - variableName: [String](../topics/String.md) - name of a [private](../commands/private.md) variable (must begin with underscore _, e.g. "_myVar")
    - defaultValue: [Anything](../topics/Anything.md) - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).
    - expectedDataTypes: [Array](../topics/Array.md) of direct Data Types - (Optional) checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.
    - expectedArrayCount: [Number](../topics/Number.md) or [Array](../topics/Array.md) - (Optional) a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.

**Returns:** [Boolean](../topics/Boolean.md) - [false](../commands/false.md) if error occurred or default value has been used, otherwise [true](../commands/true.md)

## Examples

### Example 1

```sqf
[1, 2, 3] call {
    private ["_one", "_two", "_three"];
    _one = _this select 0;
    _two = _this select 1;
    _three = _this select 2;
    // ...
};

// Same as above, only using params
[1, 2, 3] call {
    params ["_one", "_two", "_three"];
    // ...
};
```

### Example 2

```sqf
[123] call {
    params ["_myvar"];
};

// Below would produce the same result as above
123 call {
    params ["_myvar"];
};
```

### Example 3

Skipping some array elements:

```sqf
position player params ["", "", "_z"];
if (_z > 10) then {
    hint "YOU ARE FLYING!";
};
```

### Example 4

```sqf
[1, nil, 2] params ["_var1", "_var2", "_var3"];
// All 3 variables are made private but only _var1 and _var3 are defined

[1, nil, 2] params ["_var1", ["_var2", 23], "_var3"];
// All 3 variables are private and defined
```

### Example 5

```sqf
[1, 2] call {
    if (!params ["_var1", "_var2", ["_var3", true, [true]]]) exitWith {
        hint str [_var1, _var2, _var3];
    };
};
// The hint shows [1,2,true]
// Script exits, default value was used due to missing value

[1, 2, 3] call {
    if (!params ["_var1", "_var2", ["_var3", true, [true]]]) exitWith {
        hint str [_var1, _var2, _var3];
    };
};
// The hint shows [1,2,true]
// Script exits, default value was used due incorrect value type
```

### Example 6

```sqf
[1, "ok", [1, 2, 3]] call {
    if (!params [
        ["_var1", 0, [0]],
        ["_var2", "", [""]],
        ["_var3", [0,0,0], [[], objNull, 0], [2,3]]
    ]) exitWith {};
    hint "ok";
};
// Passes validation

[1, 2, [3, 4, 5]] call {
    if (!params ["_var1", "_var2", ["_var3", [], [[], objNull, 0], 0]]) exitWith {};
    hint "ok";
};
// Fails, because passed array is expected to be of 0 length, i.e. empty
```

### Example 7

```sqf
[1, 2, 3, [4, 5, 6]] call {
    params ["_one", "_two", "_three"];
    _this select 3 params ["_four", "_five", "_six"];
};
```

### Example 8

```sqf
{
    _x params ["_group", "_index"];
    // ...
} forEach waypoints group player;

fn_someFnc = {
    params ["_position", ["_direction", 0], ["_name", ""]];
    // Extract the x, y, and z from "_position" array:
    _position params ["_x", "_y", "_z"];
    // ...
};

[position player, direction player, name player] call fn_someFnc;
```

### Example 9

```sqf
player addEventHandler ["HitPart", {
    _this select 0 params ["_target", "_shooter", "_projectile"];
}];
```

## See also

[param](../commands/param.md) · [select](../commands/select.md) · # ·  this · [isEqualTypeAll](../commands/isEqualTypeAll.md) · [isEqualType](../commands/isEqualType.md) · [isEqualTypeParams](../commands/isEqualTypeParams.md) · [isEqualTypeArray](../commands/isEqualTypeArray.md) · [isEqualTypeAny](../commands/isEqualTypeAny.md)

## Community notes

**Dedmen** — 2016-11-03

With a function only taking one Parameter, it doesn't matter whether the parameter is in an array or not:

Example:

```sqf
1 call {
    params [["_number",0, [0]]];
};
```

or

```sqf
[1] call {
    params [["_number",0, [0]]];
};
```

But when the one Parameter is an array that parameter has to be inside of an array when the function is called

Example:

```sqf
[1, 2] call {
    params [["_array", [], [[]], 2]];
}; // Fails

[[1,2]] call {
    params [["_array", [], [[]], 2]];
}; // Succeeds
```

---

**7erra** — 2019-07-04

It is valid to redefine the [_this](../topics/Magic_Variables.md#this) variable and use [params](../commands/params.md) again like this:

```sqf
[1, 2, [3, 4]] call {
    params ["_one", "_two", "_this"];
    params ["_three", "_four"];
};
```

---

**AgentRev** — 2021-11-01

Here's how to validate [HashMap](../topics/HashMap.md) parameters:

```sqf
_myHashMap = createHashMapFromArray [["a",1],["b",2],["c",3]];

[_myHashMap] call {
    params [["_theHashMap",createHashMap,[createHashMap]]];
};
```

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