{"name":"params","operator":null,"title":"params","type":"command","url":"https://community.bistudio.com/wiki/params","revid":377705,"updated":"2026-01-02T09:03:38Z","groups":["Variables","Arrays"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.48"}],"since":{"game":"arma3","name":"Arma 3","version":"1.48"},"arma3_since":"1.48","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Parses input argument into array of private variables. When used without argument, as shown in main syntax, internal variable _this, which is usually available inside functions and event handlers, is used as argument.\n\nIn 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.\n\n> [!WARNING]\n> All variables names must start with underscore and be enclosed in quotes:\n\n> [!NOTE]\n> It is a good practice to make your local variables **private** (through private or params) in order to avoid overwriting a local variable of the same name.","syntaxes":[{"syntax":"params [element1, element2, ...]","since":null,"effect":null,"exec":null,"params":[{"name":"elementN","type":"String or Array","optional":true,"default":null,"description":"String or Array\n- String:name of the private variable (must begin with underscore _, e.g. \"_myVar\", or can be an empty string \"\", in which case the element is skipped)\n- Array with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]\n  - variableName: String - name of a private variable (must begin with underscore _, e.g. \"_myVar\")\n  - defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).\n  - expectedDataTypes: Array of direct Data Types -  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.\n  - expectedArrayCount: Number or Array - (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.","types":["String","Array"],"since":null,"text":"elementN: String or Array\n- String:name of the private variable (must begin with underscore _, e.g. \"_myVar\", or can be an empty string \"\", in which case the element is skipped)\n- Array with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]\n  - variableName: String - name of a private variable (must begin with underscore _, e.g. \"_myVar\")\n  - defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).\n  - expectedDataTypes: Array 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.\n  - expectedArrayCount: Number or Array - (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":{"type":"Boolean","types":["Boolean"],"description":"false if error occurred or default value has been used, otherwise true","text":"Boolean - false if error occurred or default value has been used, otherwise true"},"form":"unary","operator":null,"left":null,"right":{"text":"[element1, element2, ...]","types":["Array"]}},{"syntax":"argument params [element1, element2, ...]","since":null,"effect":null,"exec":null,"params":[{"name":"argument","type":"Anything","optional":false,"default":null,"description":"a usual array of params is expected. If a non-array argument is passed, it will be converted to 1 element array","types":["Anything"],"since":null,"text":"argument: Anything - a usual array of params is expected. If a non-array argument is passed, it will be converted to 1 element array"},{"name":"elementN","type":"String or Array","optional":true,"default":null,"description":"String or Array\n- String:name of the private variable (must begin with underscore _, e.g. \"_myVar\", or can be an empty string \"\", in which case the element is skipped)\n- Array with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]\n  - variableName: String - name of a private variable (must begin with underscore _, e.g. \"_myVar\")\n  - defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).\n  - expectedDataTypes: Array of direct Data Types -  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.\n  - expectedArrayCount: Number or Array - (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.","types":["String","Array"],"since":null,"text":"elementN: String or Array\n- String:name of the private variable (must begin with underscore _, e.g. \"_myVar\", or can be an empty string \"\", in which case the element is skipped)\n- Array with [variableName, defaultValue, expectedDataTypes, expectedArrayCount]\n  - variableName: String - name of a private variable (must begin with underscore _, e.g. \"_myVar\")\n  - defaultValue: Anything - default value to return if input element is undefined, of the wrong type or of the wrong size (if array).\n  - expectedDataTypes: Array 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.\n  - expectedArrayCount: Number or Array - (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":{"type":"Boolean","types":["Boolean"],"description":"false if error occurred or default value has been used, otherwise true","text":"Boolean - false if error occurred or default value has been used, otherwise true"},"form":"binary","operator":null,"left":{"text":"argument","types":["Anything"]},"right":{"text":"[element1, element2, ...]","types":["Array"]}}],"examples":[{"text":"```sqf\n[1, 2, 3] call {\n    private [\"_one\", \"_two\", \"_three\"];\n    _one = _this select 0;\n    _two = _this select 1;\n    _three = _this select 2;\n    // ...\n};\n\n// Same as above, only using params\n[1, 2, 3] call {\n    params [\"_one\", \"_two\", \"_three\"];\n    // ...\n};\n```","code":["[1, 2, 3] call {\n\tprivate [\"_one\", \"_two\", \"_three\"];\n\t_one = _this select 0;\n\t_two = _this select 1;\n\t_three = _this select 2;\n\t// ...\n};\n\n// Same as above, only using params\n[1, 2, 3] call {\n\tparams [\"_one\", \"_two\", \"_three\"];\n\t// ...\n};"]},{"text":"```sqf\n[123] call {\n    params [\"_myvar\"];\n};\n\n// Below would produce the same result as above\n123 call {\n    params [\"_myvar\"];\n};\n```","code":["[123] call {\n\tparams [\"_myvar\"];\n};\n\n// Below would produce the same result as above\n123 call {\n\tparams [\"_myvar\"];\n};"]},{"text":"Skipping some array elements:\n\n```sqf\nposition player params [\"\", \"\", \"_z\"];\nif (_z > 10) then {\n    hint \"YOU ARE FLYING!\";\n};\n```","code":["position player params [\"\", \"\", \"_z\"];\nif (_z > 10) then {\n\thint \"YOU ARE FLYING!\";\n};"]},{"text":"```sqf\n[1, nil, 2] params [\"_var1\", \"_var2\", \"_var3\"];\n// All 3 variables are made private but only _var1 and _var3 are defined\n\n[1, nil, 2] params [\"_var1\", [\"_var2\", 23], \"_var3\"];\n// All 3 variables are private and defined\n```","code":["[1, nil, 2] params [\"_var1\", \"_var2\", \"_var3\"];\n// All 3 variables are made private but only _var1 and _var3 are defined\n\n[1, nil, 2] params [\"_var1\", [\"_var2\", 23], \"_var3\"];\n// All 3 variables are private and defined"]},{"text":"```sqf\n[1, 2] call {\n    if (!params [\"_var1\", \"_var2\", [\"_var3\", true, [true]]]) exitWith {\n        hint str [_var1, _var2, _var3];\n    };\n};\n// The hint shows [1,2,true]\n// Script exits, default value was used due to missing value\n\n[1, 2, 3] call {\n    if (!params [\"_var1\", \"_var2\", [\"_var3\", true, [true]]]) exitWith {\n        hint str [_var1, _var2, _var3];\n    };\n};\n// The hint shows [1,2,true]\n// Script exits, default value was used due incorrect value type\n```","code":["[1, 2] call {\n\tif (!params [\"_var1\", \"_var2\", [\"_var3\", true, [true]]]) exitWith {\n\t\thint str [_var1, _var2, _var3];\n\t};\n};\n// The hint shows [1,2,true]\n// Script exits, default value was used due to missing value\n\n[1, 2, 3] call {\n\tif (!params [\"_var1\", \"_var2\", [\"_var3\", true, [true]]]) exitWith {\n\t\thint str [_var1, _var2, _var3];\n\t};\n};\n// The hint shows [1,2,true]\n// Script exits, default value was used due incorrect value type"]},{"text":"```sqf\n[1, \"ok\", [1, 2, 3]] call {\n    if (!params [\n        [\"_var1\", 0, [0]],\n        [\"_var2\", \"\", [\"\"]],\n        [\"_var3\", [0,0,0], [[], objNull, 0], [2,3]]\n    ]) exitWith {};\n    hint \"ok\";\n};\n// Passes validation\n\n[1, 2, [3, 4, 5]] call {\n    if (!params [\"_var1\", \"_var2\", [\"_var3\", [], [[], objNull, 0], 0]]) exitWith {};\n    hint \"ok\";\n};\n// Fails, because passed array is expected to be of 0 length, i.e. empty\n```","code":["[1, \"ok\", [1, 2, 3]] call {\n\tif (!params [\n\t\t[\"_var1\", 0, [0]],\n\t\t[\"_var2\", \"\", [\"\"]],\n\t\t[\"_var3\", [0,0,0], [[], objNull, 0], [2,3]]\n\t]) exitWith {};\n\thint \"ok\";\n};\n// Passes validation\n\n[1, 2, [3, 4, 5]] call {\n\tif (!params [\"_var1\", \"_var2\", [\"_var3\", [], [[], objNull, 0], 0]]) exitWith {};\n\thint \"ok\";\n};\n// Fails, because passed array is expected to be of 0 length, i.e. empty"]},{"text":"```sqf\n[1, 2, 3, [4, 5, 6]] call {\n    params [\"_one\", \"_two\", \"_three\"];\n    _this select 3 params [\"_four\", \"_five\", \"_six\"];\n};\n```","code":["[1, 2, 3, [4, 5, 6]] call {\n\tparams [\"_one\", \"_two\", \"_three\"];\n\t_this select 3 params [\"_four\", \"_five\", \"_six\"];\n};"]},{"text":"```sqf\n{\n    _x params [\"_group\", \"_index\"];\n    // ...\n} forEach waypoints group player;\n\nfn_someFnc = {\n    params [\"_position\", [\"_direction\", 0], [\"_name\", \"\"]];\n    // Extract the x, y, and z from \"_position\" array:\n    _position params [\"_x\", \"_y\", \"_z\"];\n    // ...\n};\n\n[position player, direction player, name player] call fn_someFnc;\n```","code":["{\n\t_x params [\"_group\", \"_index\"];\n\t// ...\n} forEach waypoints group player;\n\nfn_someFnc = {\n\tparams [\"_position\", [\"_direction\", 0], [\"_name\", \"\"]];\n\t// Extract the x, y, and z from \"_position\" array:\n\t_position params [\"_x\", \"_y\", \"_z\"];\n\t// ...\n};\n\n[position player, direction player, name player] call fn_someFnc;"]},{"text":"```sqf\nplayer addEventHandler [\"HitPart\", {\n    _this select 0 params [\"_target\", \"_shooter\", \"_projectile\"];\n}];\n```","code":["player addEventHandler [\"HitPart\", {\n\t_this select 0 params [\"_target\", \"_shooter\", \"_projectile\"];\n}];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["param","select","#"," this","isEqualTypeAll","isEqualType","isEqualTypeParams","isEqualTypeArray","isEqualTypeAny"],"notes":[{"user":"Dedmen","date":"2016-11-03T04:07:00Z","text":"With a function only taking one Parameter, it doesn't matter whether the parameter is in an array or not:\n\nExample:\n\n```sqf\n1 call {\n    params [[\"_number\",0, [0]]];\n};\n```\n\nor\n\n```sqf\n[1] call {\n    params [[\"_number\",0, [0]]];\n};\n```\n\nBut when the one Parameter is an array that parameter has to be inside of an array when the function is called\n\nExample:\n\n```sqf\n[1, 2] call {\n    params [[\"_array\", [], [[]], 2]];\n}; // Fails\n\n[[1,2]] call {\n    params [[\"_array\", [], [[]], 2]];\n}; // Succeeds\n```"},{"user":"7erra","date":"2019-07-04T16:54:00Z","text":"It is valid to redefine the _this variable and use params again like this:\n\n```sqf\n[1, 2, [3, 4]] call {\n    params [\"_one\", \"_two\", \"_this\"];\n    params [\"_three\", \"_four\"];\n};\n```"},{"user":"AgentRev","date":"2021-11-01T16:00:30Z","text":"Here's how to validate HashMap parameters:\n\n```sqf\n_myHashMap = createHashMapFromArray [[\"a\",1],[\"b\",2],[\"c\",3]];\n\n[_myHashMap] call {\n    params [[\"_theHashMap\",createHashMap,[createHashMap]]];\n};\n```"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Command Group: Variables","Introduced with Arma 3 version 1.48","Scripting Commands"]}