{"hash":"0xDFFBA12F","ns":"CFX","name":"GET_ENTITIES_IN_RADIUS","slug":"GET_ENTITIES_IN_RADIUS","official":true,"named":true,"luaName":"GetEntitiesInRadius","game":"cfx","apiset":"shared","returnType":"object","params":[{"name":"x","type":"float","description":"The X coordinate."},{"name":"y","type":"float","description":"The Y coordinate."},{"name":"z","type":"float","description":"The Z coordinate."},{"name":"radius","type":"float","description":"Max distance from coordinate to entity"},{"name":"entityType","type":"int","description":"Entity types see list below"},{"name":"sortByDistance","type":"BOOL","description":"Sort output entites by distance from nearest to farthest"},{"name":"models","type":"object","description":"List of allowed models its also optional"}],"returnsDescription":"An array containing entity handles for each entity.","summary":"Supported types \\[1] : Peds (including animals) and players.","descriptions":[{"source":"cfx","format":"md","body":"### Supported types\n\n*   \\[1] : Peds (including animals) and players.\n*   \\[2] : Vehicles.\n*   \\[3] : Objects (props), doors, and projectiles.\n\n### Coordinates need to be send unpacked (x,y,z)\n\n```lua\n\n-- Define the allowed model hashes\nlocal allowedModelHashes = { GetHashKey(\"p_crate03x\"), GetHashKey(\"p_crate22x\") }\n\n-- Get the player's current coordinates\nlocal playerCoords = GetEntityCoords(PlayerPedId())\n\n-- Retrieve all entities of type Object (type 3) within a radius of 10.0 units\n-- that match the allowed model hashes\n-- and sort output entities by distance\nlocal entities = GetEntitiesInRadius(playerCoords.x, playerCoords.y, playerCoords.z, 10.0, 3, true, allowedModelHashes)\n\n-- Iterate through the list of entities and print their ids\nfor i = 1, #entities do\n    local entity = entities[i]\n    print(entity)\nend\n\n```"}],"examples":[],"aliases":[],"enums":[],"related":[],"sources":["cfx"],"doc":2,"url":"https://natives.borderlinerp.com/natives/CFX/GET_ENTITIES_IN_RADIUS","markdownUrl":"https://natives.borderlinerp.com/natives/CFX/GET_ENTITIES_IN_RADIUS.md","snippets":{"lua":"local retval = GetEntitiesInRadius(x, y, z, radius, entityType, sortByDistance, models)","luaInvoke":"local retval = Citizen.InvokeNative(0xdffba12f, x, y, z, radius, entityType, sortByDistance, models, Citizen.ResultAsObject2(msgpack.unpack))","js":"const retval = GetEntitiesInRadius(x, y, z, radius, entityType, sortByDistance, models);","jsInvoke":"const retval = Citizen.invokeNative('0xdffba12f', x + 0.0000001, y + 0.0000001, z + 0.0000001, radius + 0.0000001, entityType, sortByDistance, models, Citizen.returnResultAnyway(), Citizen.resultAsObject2());","csharp":"Function.Call((Hash)0xdffba12f, x, y, z, radius, entityType, sortByDistance, models);","notes":["Float parameters: Lua integers (`10`, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write `10.0` or `value + 0.0`. The generated JS wrappers add `0.0000001` to non-zero floats for the same reason."]}}