RedM Index logoRedM Index
NativesHashesClothesBlipsPropsItem Tool
Sign inGet started

Reference

  • Natives
  • Hashes
  • Clothes
  • Blips
  • Props

Namespace

  1. Reference
  2. Natives
  3. GET_ENTITIES_IN_RADIUS

GET_ENTITIES_IN_RADIUS

### Supported types * \[1] : Peds (including animals) and players. * \[2] : Vehicles. * \[3] : Objects (props), doors, and projectiles. ### Coordinates need to be send unpacked (x,y,z) ```lua -- Define the allowed model hashes local allowedModelHashes = { GetHashKey("p_crate03x"), GetHashKey("p_crate22x") } -- Get the player's current coordinates local playerCoords = GetEntityCoords(PlayerPedId()) -- Retrieve all entities of type Object (type 3) within a radius of 10.0 units -- that match the allowed model hashes -- and sort output entities by distance local entities = GetEntitiesInRadius(playerCoords.x, playerCoords.y, playerCoords.z, 10.0, 3, true, allowedModelHashes) -- Iterate through the list of entities and print their ids for i = 1, #entities do local entity = entities[i] print(entity) end ```

CFX

Signature

lua
GetEntitiesInRadius(0.0, 0.0, 0.0, 0.0, 0, true, models)
-- returns object

Parameters

NameTypeDescription
floatThe X coordinate.
floatThe Y coordinate.
floatThe Z coordinate.
floatMax distance from coordinate to entity
intEntity types see list below
BOOLSort output entites by distance from nearest to farthest
objectList of allowed models its also optional

Usage

lua
GetEntitiesInRadius(0.0, 0.0, 0.0, 0.0, 0, true, models)

Generated from the native name, hash, and parameter list. Add a real example.

Details

Hash
API set
Source
cfx

Source: cfx

On this page

  • Signature
  • Parameters
  • Usage
  • Details