RedM Natives

CREATE_VEHICLE

Creates a vehicle with the specified model at the specified position.

Hash0xDD75460A
Runtime nameCreateVehicle
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

Entity CREATE_VEHICLE(Hash modelHash, float x, float y, float z, float heading, BOOL isNetwork, BOOL netMissionEntity);

Parameters

NameTypeDescription
modelHashHash

The model of vehicle to spawn.

xfloat

Spawn coordinate X component.

yfloat

Spawn coordinate Y component.

zfloat

Spawn coordinate Z component.

headingfloat

Heading to face towards, in degrees.

isNetworkBOOL

Whether to create a network object for the vehicle. If false, the vehicle exists only locally.

netMissionEntityBOOL

Whether to register the vehicle as pinned to the script host in the R* network model.

Returns Entity — A script handle (fwScriptGuid index) for the vehicle, or `0` if the vehicle failed to be created.

Description

Cfx.re native reference

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

This is the server-side RPC native equivalent of the client native CREATE_VEHICLE.

Usage

Lua
local retval = CreateVehicle(modelHash, x, y, z, heading, isNetwork, netMissionEntity)

-- always works, by hash
local retval = Citizen.InvokeNative(0xdd75460a, modelHash, x, y, z, heading, isNetwork, netMissionEntity, Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const retval = CreateVehicle(modelHash, x, y, z, heading, isNetwork, netMissionEntity);

// by hash
const retval = Citizen.invokeNative('0xdd75460a', modelHash, x + 0.0000001, y + 0.0000001, z + 0.0000001, heading + 0.0000001, isNetwork, netMissionEntity, Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
int retval = Function.Call<int>((Hash)0xdd75460a, modelHash, x, y, z, heading, isNetwork, netMissionEntity);
  • Hash parameters: the named function also accepts a string and hashes it for you; Citizen.InvokeNative needs the number — pass joaat("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. Write 10.0 or value + 0.0. The generated JS wrappers add 0.0000001 to non-zero floats for the same reason.

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.