inAreaArrayIndexes: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{RV|type=command |game1= arma3 |version1= 2.14 |branch= dev |gr1= Triggers |gr2= Markers |gr3= Locations |gr4= Positions |descr= Checks if positions given in Array...")
 
No edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 3: Line 3:
|game1= arma3
|game1= arma3
|version1= 2.14
|version1= 2.14
|branch= dev


|gr1= Triggers
|gr1= Triggers
Line 13: Line 12:
|gr4= Positions
|gr4= Positions


|descr= Checks if positions given in [[Array]] of positions are within the given area and returns the indexes of matching elements.
|gr5= Groups
 
|descr= Returns indices of positions that are within the provided area.
 
{{Feature|important|Unlike [[inAreaArray]], all positions sent to this command are treated as [[Position#PositionASL|PositionASL]] but the center as [[PositionAGL]].}}
{{Feature|important|Since {{GVI|arma3|2.20|size= 0.75}} this command is fully compatible with [[inAreaArray]], i.e by default all positions given as [[Array]] or as objects are treated as [[PositionAGL]]. There is also an option to force them to [[PositionWorld]] format.}}


|s1= positions [[inAreaArrayIndexes]] area
|s1= positions [[inAreaArrayIndexes]] area


|p1= positions: [[Array]] of [[Object]]s and/or [[Position]]s and/or [[Location]]s and/or [[String]]s and/or [[Group]]s, where:
|p1= positions: [[Array]] of [[Object]]s and/or [[Position]]s
* [[Object]]s - entities
* [[Position]]s - 2D or 3D positions
* [[Location]]s - locations
* [[String]]s - markers
* [[Group]]s - AI groups, the position is the [[leader]] position


|p2= area: [[Array]] or [[Object]] or [[Location]] or [[String]], where:
|p2= area: [[Object]], [[Location]] or [[String]] - the defined area:
* [[Array]] - in format [center, a, b, angle, isRectangle, c] or polygon in format [point1, point2, point2,...]
* [[Object]] - trigger
* [[Object]] - trigger
* [[Location]] - location
* [[Location]] - location
* [[String]] - marker
* [[String]] - marker name
 
|r1= [[Array]]: [[Number]]s - indexes of matched positions in positions array
 
|s2= positions [[inAreaArrayIndexes]] [centre, a, b, angle, isRectangle, c, usePosWorld]
 
|p21= positions: [[Array]] - [[Object]]s and/or [[Position]]s to check (see note in description)
 
|p22= centre: [[Array]] - [[Position]] [[Object]] or [[Group]] (see note in description)
 
|p23= a: [[Number]] - x axis (x / 2)
 
|p24= b: [[Number]] - y axis (y / 2)
 
|p25= angle: [[Number]] - (Optional, default 0) rotation angle


|r1= [[Array]] of [[Number]]s - indexes of matching elements in 'positions' [[Array]]
|p26= isRectangle: [[Boolean]] - (Optional, default [[false]]) [[true]] if rectangle, [[false]] if ellipse


|x1= <sqf>allUnits inAreaArrayIndexes myTrigger;</sqf>
|p27= c: [[Number]] - (Optional, default -1: unlimited) z axis (z / 2)


|x2= <sqf>allMapMarkers inAreaArrayIndexes "myMarker";</sqf>
|p28= usePosWorld: [[Boolean]] - (Optional, default [[false]]) set to [[true]] to treat all positions as [[PositionWorld]]
|p28since= Arma3 2.20


|x3= <sqf>allPlayers inAreaArrayIndexes myLocation;</sqf>
|r2= [[Array]]: [[Number]]s - indexes of matched positions in positions array


|x4= <sqf>allGroups inAreaArrayIndexes [[100, 100, 0], 20, 30, 45, false, 10];</sqf>
|s3= positions [[inAreaArrayIndexes]] [pos1, pos2, pos3,...]
|p41= positions: [[Array]] - [[Object]]s and/or [[Position]]s to check.
|p42 = posN: [[Position]] - polygon vertices in 2d or 3d format (see [[inPolygon]])
|r3= [[Array]]: [[Number]]s - indexes of matched positions in positions array


|x1= <sqf>
private _players = call BIS_fnc_listPlayers;
private _indices = _players inAreaArrayIndexes _marker;
{
private _player = _players select _x;
["You are in the marker!"] remoteExec ["hint", _player];
} forEach _indices;
</sqf>


|seealso= [[inAreaArray]] [[inArea]] [[triggerArea]]
|seealso= [[inAreaArray]] [[inArea]] [[triggerArea]]
}}
}}

Latest revision as of 22:37, 1 November 2024

Hover & click on the images for description

Description

Description:
Returns indices of positions that are within the provided area.
Unlike inAreaArray, all positions sent to this command are treated as PositionASL but the center as PositionAGL.
Since Arma 3 logo black.png2.20 this command is fully compatible with inAreaArray, i.e by default all positions given as Array or as objects are treated as PositionAGL. There is also an option to force them to PositionWorld format.
Groups:
TriggersMarkersLocationsPositionsGroups

Syntax 1

Syntax:
positions inAreaArrayIndexes area
Parameters:
positions: Array of Objects and/or Positions
area: Object, Location or String - the defined area:
Return Value:
Array: Numbers - indexes of matched positions in positions array

Syntax 2

Syntax:
positions inAreaArrayIndexes [centre, a, b, angle, isRectangle, c, usePosWorld]
Parameters:
positions: Array - Objects and/or Positions to check (see note in description)
centre: Array - Position Object or Group (see note in description)
a: Number - x axis (x / 2)
b: Number - y axis (y / 2)
angle: Number - (Optional, default 0) rotation angle
isRectangle: Boolean - (Optional, default false) true if rectangle, false if ellipse
c: Number - (Optional, default -1: unlimited) z axis (z / 2)
since Arma 3 logo black.png2.20
usePosWorld: Boolean - (Optional, default false) set to true to treat all positions as PositionWorld
Return Value:
Array: Numbers - indexes of matched positions in positions array

Syntax 3

Syntax:
positions inAreaArrayIndexes [pos1, pos2, pos3,...]
Parameters:
positions: Array - Objects and/or Positions to check.
posN: Position - polygon vertices in 2d or 3d format (see inPolygon)
Return Value:
Array: Numbers - indexes of matched positions in positions array

Examples

Example 1:
private _players = call BIS_fnc_listPlayers; private _indices = _players inAreaArrayIndexes _marker; { private _player = _players select _x; ["You are in the marker!"] remoteExec ["hint", _player]; } forEach _indices;

Additional Information

See also:
inAreaArray inArea triggerArea

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note