Native referenceFiveM

CREATE_VEHICLE

0xAF35D0D2583051B0 VEHICLE
FUNCTION SIGNATURE
Vehicle CREATE_VEHICLE(Hash modelHash, float x, float y, float z, float heading, BOOL isNetwork, BOOL netMissionEntity);
Property Value
Native Name CREATE_VEHICLE
Hash 0xAF35D0D2583051B0
Return Type Vehicle
Parameters modelHash (Hash), x (float), y (float), z (float), heading (float), isNetwork (BOOL), netMissionEntity (BOOL)

Description: Creates a vehicle with the specified model at the specified position. This vehicle will initially be owned by the creating script as a mission entity, and the model should be loaded already (e.g. using REQUEST_MODEL).

NativeDB Added Parameter 8: BOOL p7

Parameters

  • modelHash (Hash) — The model of vehicle 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 vehicle. If false, the vehicle exists only locally.
  • netMissionEntity (BOOL) — Whether to register the vehicle as pinned to the script host in the R* network model.

Examples

local ModelHash = `adder` -- Use Compile-time hashes to get the hash of this model
if not IsModelInCdimage(ModelHash) then return end
RequestModel(ModelHash) -- Request the model
while not HasModelLoaded(ModelHash) do -- Waits for the model to load
  Wait(0)
end
local MyPed = PlayerPedId()
local Vehicle = CreateVehicle(ModelHash, GetEntityCoords(MyPed), GetEntityHeading(MyPed), true, false) -- Spawns a networked vehicle on your current coords
SetModelAsNoLongerNeeded(ModelHash) -- removes model from game memory as we no longer need it
Back to VEHICLE