GetClosestPed
Docslocal retval, outPed = GetClosestPed(x, y, z, radius, p4, p5, p7, p8, pedType)Description
Gets the closest ped in a radius.
Ped Types:
Any ped = -1
Player = 1
Male = 4
Female = 5
Cop = 6
Human = 26
SWAT = 27
Animal = 28
Army = 29
------------------
P4 P5 P7 P8
1 0 x x = return nearest walking Ped
1 x 0 x = return nearest walking Ped
x 1 1 x = return Ped you are using
0 0 x x = no effect
0 x 0 x = no effect
x = can be 1 or 0. Does not have any obvious changes.
This function does not return ped who is:
1. Standing still
2. Driving
3. Fleeing
4. Attacking
This function only work if the ped is:
1. walking normally.
2. waiting to cross a road.
Note: PED::GET_PED_NEARBY_PEDS works for more peds.Parameters
| Name | Type | Description |
|---|---|---|
x | float | — |
y | float | — |
z | float | — |
radius | float | — |
p4 | BOOL | — |
p5 | BOOL | — |
outPed | Ped* | — |
p7 | BOOL | — |
p8 | BOOL | — |
pedType | int | — |
Quick Snippet: Get Coordinatesxyz
xyzAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Ped HandleoutPed
outPedUse this to get the player ped handle for this native.
-- Get the player's ped handle (client-side)
local ped = PlayerPedId()
print("Ped handle: " .. ped)
-- For a specific player's ped (server-side):
-- local targetPed = GetPlayerPed(source)Ped Models

mp_m_freemode_01
player_zero
ig_agatha
s_m_y_cop_01
s_m_m_gaffer_01
g_m_m_armboss_01
a_c_boar
a_m_m_bevhills_01Returns
BOOLReturns TRUE (1) or FALSE (0).