CreatePed
Is equal to the standard one but dont need to load or request the model
Argument | Data Type | Needed | Default | Description |
---|---|---|---|---|
Model | string/number | - | The hash or the name of the model | |
Coords | vector3/number | - | The coordinates to create the ped (can be an vector3 or you can insert it one by one) | |
Heading | number | - | The heading to create the ped | |
IsNetwork | boolean | - | Whether to create a network object for the ped. If false, the ped exists only locally. |
Returns
Data Type | Description |
---|---|
ped | A script handle (fwScriptGuid index) for the ped, or 0 if the ped failed to be created. |
netId | The net id |
Dont need to be called every frame
Example
Using vector3
local ped, netId = CreatePed("cs_dale", vector3(0.0, 0.0, 0.0), 5.0, true)
local ped, netId = CreatePed("cs_dale", 0.0, 0.0, 0.0, 5.0, true)
Old method
local modelHash = GetHashKey("cs_dale")
if not HasModelLoaded(modelHash) then
RequestModel(modelHash);
while not HasModelLoaded(modelHash) do
Citizen.Wait(1);
end
end
local ped = CreatePed(0, modelHash, 0.0, 0.0, 0.0, 5.0, true, false)
SetModelAsNoLongerNeeded(modelHash)
Using old native
although i dont recommend it, you can use the old native via old_CreatePed
Last update: April 12, 2022
Created: July 2, 2021
Created: July 2, 2021