RedM Natives

GET_CLOSEST_PED

Gets the closest ped in a radius.

Hash0xC33AB876A77F8164
Runtime nameGetClosestPed
NamespacePED
SideClient
NameOfficial
Docs
Since build1207
GTA V hash0xC33AB876A77F8164

Signature

BOOL GET_CLOSEST_PED(float x, float y, float z, float radius, BOOL p4, BOOL p5, Ped* outPed, BOOL p7, BOOL p8, BOOL p9, int pedType);

Parameters

NameTypeDescription
xfloat—
yfloat—
zfloat—
radiusfloat—
p4BOOL—
p5BOOL—
outPedPed*—
p7BOOL—
p8BOOL—
p9BOOL—
pedTypeint—

Returns BOOL

Description

Gets the closest ped in a radius.

Usage

Lua
local retval, outPed = GetClosestPed(x, y, z, radius, p4, p5, p7, p8, p9, pedType)

-- always works, by hash
local retval, outPed = Citizen.InvokeNative(0xC33AB876A77F8164, x, y, z, radius, p4, p5, Citizen.PointerValueInt(), p7, p8, p9, pedType, Citizen.ReturnResultAnyway())
JavaScript and C#
JavaScript
const [retval, outPed] = GetClosestPed(x, y, z, radius, p4, p5, p7, p8, p9, pedType);

// by hash
const [retval, outPed] = Citizen.invokeNative('0xC33AB876A77F8164', x + 0.0000001, y + 0.0000001, z + 0.0000001, radius + 0.0000001, p4, p5, Citizen.pointerValueInt(), p7, p8, p9, pedType, Citizen.returnResultAnyway());
C#
var outPed = new OutputArgument();
bool retval = Function.Call<bool>((Hash)0xC33AB876A77F8164, x, y, z, radius, p4, p5, outPed, p7, p8, p9, pedType);
// outPed.GetResult<int>()
  • 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.
  • Pointer (out) arguments are not passed in Lua/JS: their values are returned after the result, in order.

Sources

alloc8or RDR3 NativeDB

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.