PedClient

getRandomPedAtCoord

GET_RANDOM_PED_AT_COORD0x876046A8E3A4B71C

The GTA V native GET_RANDOM_PED_AT_COORD of the PED namespace, as LS:MP client scripts call it: the global function getRandomPedAtCoord, in JavaScript and in Lua.

SignatureJavaScript
getRandomPedAtCoord(
  x: number,
  y: number,
  z: number,
  xRadius: number,
  yRadius: number,
  zRadius: number,
  pedType: number
): Ped
SignatureLua
getRandomPedAtCoord(
  x: number,
  y: number,
  z: number,
  xRadius: number,
  yRadius: number,
  zRadius: number,
  pedType: integer
): Ped

Usage

JavaScript
const ped = getRandomPedAtCoord(x, y, z, xRadius, yRadius, zRadius, pedType);
Lua
local ped = getRandomPedAtCoord(x, y, z, xRadius, yRadius, zRadius, pedType)

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 ped = getRandomPedAtCoord(pos, radius, pedType);
Lua · with vectors
local ped = getRandomPedAtCoord(pos, radius, pedType)

Parameters

ParameterTypeJavaScriptLua
xfloatnumbernumber
yfloatnumbernumber
zfloatnumbernumber
xRadiusfloatnumbernumber
yRadiusfloatnumbernumber
zRadiusfloatnumbernumber
pedTypeintnumberinteger

Returns

Ped JavaScript number, Lua integer

Game handle of a ped. 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.

Gets a random ped in the x/y/zRadius near the x/y/z coordinates passed.

Ped Types:
Any = -1
Player = 1
Male = 4
Female = 5
Cop = 6
Human = 26
SWAT = 27
Animal = 28
Army = 29

Reference

Namespace
Ped PED
In the game
Ped GET_RANDOM_PED_AT_COORD(float x, float y, float z, float xRadius, float yRadius, float zRadius, int pedType)
Hash
0x876046A8E3A4B71C

Open in the interactive natives reference