Returns only the closest entities of the specified type (or types) at the specified position, in the given range, dimension and limit.
Example
// Returns closest players and vehicles (from 0 to 2 entities inclusive, because limit is 2) // in a range equal to 3 and dimension equal to 0 const playersAndVehicles = alt.getClosestEntities( alt.Vector3.zero,// position 3.0,// range 0,// dimension 2,// limit alt.BaseObjectFilterType.Player | alt.BaseObjectFilterType.Vehicle, ); // Same but only players const players = alt.getClosestEntities( alt.Vector3.zero,// position 3.0,// range 0,// dimension 2,// limit alt.BaseObjectFilterType.Player, );
Remarks
If two entities are closer than 1 unit to a position, it is not determined which one will be included.
For example, if there is a vehicle at 0, 1.5, 0 and player at 0, 1.0, 0,
then if we pass position as new alt.Vector3(0, 0, 0) and limit as 1 vehicle may be returned but the player will not.
Returns only the closest entities of the specified type (or types) at the specified position, in the given range, dimension and limit.
Example
Remarks
If two entities are closer than 1 unit to a position, it is not determined which one will be included. For example, if there is a vehicle at 0, 1.5, 0 and player at 0, 1.0, 0, then if we pass
position
asnew alt.Vector3(0, 0, 0)
andlimit
as1
vehicle may be returned but the player will not.