getClosestObjectOfType
GET_CLOSEST_OBJECT_OF_TYPE0xE143FA2249364369The GTA V native GET_CLOSEST_OBJECT_OF_TYPE of the OBJECT namespace, as LS:MP client scripts call it: the global function getClosestObjectOfType, in JavaScript and in Lua.
getClosestObjectOfType(
x: number,
y: number,
z: number,
radius: number,
modelHash: Hash,
isMission: boolean,
p6: boolean,
p7: boolean
): ObjectgetClosestObjectOfType(
x: number,
y: number,
z: number,
radius: number,
modelHash: Hash,
isMission: boolean,
p6: boolean,
p7: boolean
): ObjectUsage
JavaScript
const object = getClosestObjectOfType(x, y, z, radius, modelHash, isMission, p6, p7);Lua
local object = getClosestObjectOfType(x, y, z, radius, modelHash, isMission, p6, p7)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
JavaScript · with vectors
const object = getClosestObjectOfType(pos, radius, modelHash, isMission, p6, p7);Lua · with vectors
local object = getClosestObjectOfType(pos, radius, modelHash, isMission, p6, p7)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
x | float | number | number |
y | float | number | number |
z | float | number | number |
radius | float | number | number |
modelHash | Hash | number | integer |
isMission | BOOL | boolean | boolean |
p6 | BOOL | boolean | boolean |
p7 | BOOL | boolean | boolean |
Returns
Object JavaScript number, Lua integerGame handle of an object (prop). Not an LS:MP netId. Convert one with lsmp.getEntityFromNetId.
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
Has 8 params in the latest patches.
isMission - if true doesn't return mission objects
Reference
- Namespace
- Object OBJECT
- In the game
Object GET_CLOSEST_OBJECT_OF_TYPE(float x, float y, float z, float radius, Hash modelHash, BOOL isMission, BOOL p6, BOOL p7)- Hash
0xE143FA2249364369