Creating a Ped - jorjic/fivem-docs GitHub Wiki
function myCreatePed()
--Obtain the hash of the model we want
local Hash = GetHashKey( "s_f_y_cop_01" )
--If the model is not loaded, load it
if not HasModelLoaded( Hash ) then
RequestModel( Hash )
--Wait 200ms to load the model into memory
Wait( 200 )
end
--Find the position of our local player
local Coords = GetEntityCoords( GetPlayerPed( -1 ) )
local Ped = CreatePed( 6, Hash, Coords.x, Coords.y, Coords.z, 0.0, false, true )
--7th positional argument is a boolean value for networking the ped. Set to true for network interaction.
--Let's give our ped a weapon
local WeaponHash = GetHashKey( "WEAPON_NIGHTSTICK" )
GiveWeaponToPed( Ped, WeaponHash, -1, false, true )
end