The Lab
OBJECT native

GET_CLOSEST_OBJECT_OF_TYPE

returns Object8 paramsbuild 1207

Returns the closest object of modelHash within radius of the given coordinates, or 0 if none is found.

Signature

C
Object GET_CLOSEST_OBJECT_OF_TYPE(float x, float y, float z, float radius, Hash modelHash, BOOL missionScriptObject, BOOL scriptHostObject, BOOL networkObject); // 0xE143FA2249364369 b1207

Parameters

#NameType
1xfloat
2yfloat
3zfloat
4radiusfloat
5modelHashHash
6missionScriptObjectBOOL
7scriptHostObjectBOOL
8networkObjectBOOL

Facts

Facts about GET_CLOSEST_OBJECT_OF_TYPE
Name
GET_CLOSEST_OBJECT_OF_TYPE
Hash
0xE143FA2249364369
Namespace
Returns
Object
Game build
1207

Examples

Calls by hash work in every RedM runtime. Replace the placeholder arguments with your own values.

Lua
local objectOut = Citizen.InvokeNative(0xE143FA2249364369, -- GET_CLOSEST_OBJECT_OF_TYPE
  0.0, -- float x
  0.0, -- float y
  0.0, -- float z
  0.0, -- float radius
  GetHashKey("a_c_horse_arabian_white"), -- Hash modelHash
  false, -- BOOL missionScriptObject
  false, -- BOOL scriptHostObject
  false, -- BOOL networkObject
  Citizen.ResultAsInteger()
)
print(objectOut)
JavaScript
// Whole JS numbers are sent as integers: pass floats like 1.5 (or n + 0.0000001), never 1.
const objectOut = Citizen.invokeNative("0xE143FA2249364369", // GET_CLOSEST_OBJECT_OF_TYPE
  0.0, // float x
  0.0, // float y
  0.0, // float z
  0.0, // float radius
  GetHashKey("a_c_horse_arabian_white"), // Hash modelHash
  false, // BOOL missionScriptObject
  false, // BOOL scriptHostObject
  false, // BOOL networkObject
  Citizen.resultAsInteger()
);
console.log(objectOut)
C#
int objectOut = Function.Call<int>((Hash)0xE143FA2249364369, // GET_CLOSEST_OBJECT_OF_TYPE
  0.0f, // float x
  0.0f, // float y
  0.0f, // float z
  0.0f, // float radius
  (uint)API.GetHashKey("a_c_horse_arabian_white"), // Hash modelHash
  false, // BOOL missionScriptObject
  false, // BOOL scriptHostObject
  false // BOOL networkObject
);
All OBJECT natives

Facts compiled from community research (alloc8or/rdr3-nativedb-data, femga/rdr3_discoveries); descriptions and examples by The Lab.