createVehicle
CREATE_VEHICLE0xAF35D0D2583051B0The GTA V native CREATE_VEHICLE of the VEHICLE namespace, as LS:MP client scripts call it: the global function createVehicle, in JavaScript and in Lua.
createVehicle(
modelHash: Hash,
x: number,
y: number,
z: number,
heading: number,
isNetwork: boolean,
bScriptHostVeh: boolean,
p7: boolean
): VehiclecreateVehicle(
modelHash: Hash,
x: number,
y: number,
z: number,
heading: number,
isNetwork: boolean,
bScriptHostVeh: boolean,
p7: boolean
): VehicleUsage
JavaScript
const vehicle = createVehicle(modelHash, x, y, z, heading, isNetwork, bScriptHostVeh, p7);Lua
local vehicle = createVehicle(modelHash, x, y, z, heading, isNetwork, bScriptHostVeh, p7)Three consecutive numbers can be given as one vector: { x, y, z } (or [x, y, z]) in JavaScript, a Vector3 in Lua.
JavaScript · with vectors
const vehicle = createVehicle(modelHash, pos, heading, isNetwork, bScriptHostVeh, p7);Lua · with vectors
local vehicle = createVehicle(modelHash, pos, heading, isNetwork, bScriptHostVeh, p7)Parameters
| Parameter | Type | JavaScript | Lua |
|---|---|---|---|
modelHash | Hash | number | integer |
x | float | number | number |
y | float | number | number |
z | float | number | number |
heading | float | number | number |
isNetwork | BOOL | boolean | boolean |
bScriptHostVeh | BOOL | boolean | boolean |
p7 | BOOL | boolean | boolean |
Returns
Vehicle JavaScript number, Lua integerGame handle of a vehicle. Not an LS:MP netId. Convert one with lsmp.getEntityFromNetId.
Notes
From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.
p7 when set to true allows you to spawn vehicles under -100 z.
Full list of vehicles by DurtyFree: https://github.com/DurtyFree/gta-v-data-dumps/blob/master/vehicles.json
Reference
- Namespace
- Vehicle VEHICLE
- In the game
Vehicle CREATE_VEHICLE(Hash modelHash, float x, float y, float z, float heading, BOOL isNetwork, BOOL bScriptHostVeh, BOOL p7)- Hash
0xAF35D0D2583051B0