CreateVehicle
Is equal to the standard one but dont need to load or request the model
Argument | Data Type | Needed | Default | Description |
---|---|---|---|---|
ModelHash | string/hash | - | The hash or the name of the model | |
Coords | vector3/number | - | The coordinates to create the object (can be an vector3 or you can insert it one by one) | |
Heading | number | 0 | Heading to face towards, in degrees. | |
IsNetwork | boolean | false | Whether to create a network object for the vehicle. If false, the vehicle exists only locally. | |
NetMissionEntity | boolean | false | Whether to register the vehicle as pinned to the script host in the R* network model. |
Returns
Data Type | Description |
---|---|
vehicle | A script handle (fwScriptGuid index) for the vehicle, or 0 if the vehicle failed to be created |
netId | The net id |
Dont need to be called every frame
Example
Using vector3
local veh, netId = CreateVehicle("t20", vector3(0.0, 0.0, 0.0), 0.0, true, false)
local veh, netId = CreateVehicle("t20", 0.0, 0.0, 0.0, 0.0, true, false)
Old method
local modelHash = GetHashKey("t20")
if not HasModelLoaded(modelHash) then
RequestModel(modelHash);
while not HasModelLoaded(modelHash) do
Citizen.Wait(1);
end
end
local obj = CreateVehicle(modelHash, 0.0, 0.0, 0.0, 0.0, true, false)
SetModelAsNoLongerNeeded(modelHash)
Using old native
although i dont recommend it, you can use the old native via old_CreateVehicle
Last update: April 12, 2022
Created: June 27, 2021
Created: June 27, 2021