# PED::GET_CLOSEST_PED

- **Hash:** `0xC33AB876A77F8164`
- **Namespace:** PED
- **Runtime name (Lua/JS):** `GetClosestPed`
- **Side:** client (game native)
- **Name status:** official
- **Documentation:** described
- **Since game build:** 1207
- **URL:** https://natives.borderlinerp.com/natives/PED/GET_CLOSEST_PED

## Signature

```c
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

- `x` (`float`)
- `y` (`float`)
- `z` (`float`)
- `radius` (`float`)
- `p4` (`BOOL`)
- `p5` (`BOOL`)
- `outPed` (`Ped*`)
- `p7` (`BOOL`)
- `p8` (`BOOL`)
- `p9` (`BOOL`)
- `pedType` (`int`)

## Returns

`BOOL`

## Description

Gets the closest ped in a radius.

## Usage

### Lua

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

-- always available, by hash
local retval, outPed = Citizen.InvokeNative(0xC33AB876A77F8164, x, y, z, radius, p4, p5, Citizen.PointerValueInt(), p7, p8, p9, pedType, Citizen.ReturnResultAnyway())
```

### JavaScript

```js
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#

```csharp
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.*
