Description
Checks whether value is in array, unit is in vehicle, position is inside location or ANSI string is part of other ANSI string. If Unicode support is desired, see forceUnicode.
Note
String comparison is case-sensitive (see Examples 2 and 6).
Syntax
Syntax 1
value in array
Parameters:
value: Anything - any value (cannot match Array before Arma 3)
array: Array - array of values
Returns: Boolean
Syntax 2
unit in vehicle
Parameters:
Returns: Boolean
Syntax 3
since arma3 0.50
position in location
Parameters:
Returns: Boolean
Syntax 4
since arma3 1.96
needle in haystack
Parameters:
needle: String - string to search for
haystack: String - string to search in
Returns: Boolean
Syntax 5
since arma3 2.02
key in hashMap
Parameters:
Returns: Boolean
Examples
Example 1
1 in [0, 1, 2];
Example 2
private _myArray = ["Aaa", "AAa", "AAA"];
"aaa" in _myArray;
"AAa" in _myArray;
_myArray findIf { _x == "aaa"; } != -1;
({
if (_x == "aaa") exitWith { _forEachIndex };
-1
} forEach _myArray) != -1;
{ if (_x == "aaa") exitWith { 1 } } count _myArray > 0;
{ _x == "aaa"; } count _myArray > 0;
Example 3
[1,2,3] in [[1,2,3], [4,5,6]];
Example 4
private _isInCar = player in Car;
Example 5
private _isInside = [1000,2000,0] in MyLocation;
Example 6
private _isInString = "foo" in "foobar";
_isInString = "Foo" in "foobar";
Example 7
private _onFoot = _unit in _unit;
Other options:
private _onFoot = vehicle _unit == _unit;
private _onFoot = isNull objectParent _unit;
See also
inPolygon · inArea · find · findIf · toArray · forceUnicode
From a description note:
<unit> in <vehicle> literally does this: vehicle <unit> == <vehicle>. If <vehicle> is the same as <unit> the expression will return true for when the <unit> is on foot and false for when <unit> is in vehicle (see example 7 & 8).