CREATE_PED
Creates a ped (biped character, pedestrian, actor) with the specified model at the specified position and heading.
Signature
Entity CREATE_PED(int pedType, Hash modelHash, float x, float y, float z, float heading, BOOL isNetwork, BOOL bScriptHostPed);Parameters
| Name | Type | Description |
|---|---|---|
pedType | int | Unused. Peds get set to CIVMALE/CIVFEMALE/etc. no matter the value specified. |
modelHash | Hash | The model of ped to spawn. |
x | float | Spawn coordinate X component. |
y | float | Spawn coordinate Y component. |
z | float | Spawn coordinate Z component. |
heading | float | Heading to face towards, in degrees. |
isNetwork | BOOL | Whether to create a network object for the ped. If false, the ped exists only locally. |
bScriptHostPed | BOOL | Whether to register the ped as pinned to the script host in the R* network model. |
Returns Entity — A script handle (fwScriptGuid index) for the ped, or `0` if the ped failed to be created.
Description
Creates a ped (biped character, pedestrian, actor) with the specified model at the specified position and heading. This ped will initially be owned by the creating script as a mission entity, and the model should be loaded already (e.g. using REQUEST_MODEL).
This is the server-side RPC native equivalent of the client native CREATE_PED.
Usage
local retval = CreatePed(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed)
-- always works, by hash
local retval = Citizen.InvokeNative(0x389ef71, pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed, Citizen.ResultAsInteger())JavaScript and C#
const retval = CreatePed(pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed);
// by hash
const retval = Citizen.invokeNative('0x389ef71', pedType, modelHash, x + 0.0000001, y + 0.0000001, z + 0.0000001, heading + 0.0000001, isNetwork, bScriptHostPed, Citizen.returnResultAnyway(), Citizen.resultAsInteger());int retval = Function.Call<int>((Hash)0x389ef71, pedType, modelHash, x, y, z, heading, isNetwork, bScriptHostPed);- Hash parameters: the named function also accepts a string and hashes it for you;
Citizen.InvokeNativeneeds the number — passjoaat("name")or a backtick literal like`name`. - Float parameters: Lua integers (
10, or whole numbers decoded from NUI/JSON) are sent as ints and read as garbage. Write10.0orvalue + 0.0. The generated JS wrappers add0.0000001to non-zero floats for the same reason.
Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.