PedClient

createRandomPed

CREATE_RANDOM_PED0xB4AC7D0CF06BFE8F

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

SignatureJavaScript
createRandomPed(posX: number, posY: number, posZ: number): Ped
SignatureLua
createRandomPed(posX: number, posY: number, posZ: number): Ped

Usage

JavaScript
const ped = createRandomPed(posX, posY, posZ);
Lua
local ped = createRandomPed(posX, posY, posZ)

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 = createRandomPed(pos);
Lua · with vectors
local ped = createRandomPed(pos)

Parameters

ParameterTypeJavaScriptLua
posXfloatnumbernumber
posYfloatnumbernumber
posZfloatnumbernumber

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.

vb.net

Dim ped_handle As Integer
                    With Game.Player.Character
                        Dim pos As Vector3 = .Position + .ForwardVector * 3
                        ped_handle = Native.Function.Call(Of Integer)(Hash.CREATE_RANDOM_PED, pos.X, pos.Y, pos.Z)
                    End With

Creates a Ped at the specified location, returns the Ped Handle.
Ped will not act until setPedAsNoLongerNeeded is called.

Reference

Namespace
Ped PED
In the game
Ped CREATE_RANDOM_PED(float posX, float posY, float posZ)
Hash
0xB4AC7D0CF06BFE8F

Open in the interactive natives reference