CreateVehicleServerSetter
Docslocal retval = CreateVehicleServerSetter(modelHash, type, x, y, z, heading)Description
Equivalent to CREATE_VEHICLE, but it uses 'server setter' logic (like the former CREATE_AUTOMOBILE) as a workaround for
reliability concerns regarding entity creation RPC.
Unlike CREATE_AUTOMOBILE, this supports other vehicle types as well.
Parameters
| Name | Type | Description |
|---|---|---|
modelHash | Hash | The model of vehicle to spawn. |
type | char* | The appropriate vehicle type for the model info. Can be one of `automobile`, `bike`, `boat`, `heli`, `plane`, `submarine`, `trailer`, and (potentially), `train`. This should be the same type as the `type` field in `vehicles.meta`. |
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. |
Quick Snippet: Get Coordinatesxyzheading
xyzheadingAdd this command to your client script to retrieve precise locations in-game.
-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)
print(output)
TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)Quick Snippet: Get Vehicle→ Vehicle
→ VehicleUse this to get the current vehicle handle for this native.
-- Get the vehicle the player is currently in
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
if vehicle ~= 0 then
print("Vehicle handle: " .. vehicle)
print("Model: " .. GetEntityModel(vehicle))
else
print("Player is not in a vehicle")
endQuick Snippet: Load Model HashmodelHash
modelHashModels must be loaded before use. This snippet handles requesting and releasing properly.
-- Properly load a model before spawning/using it
local modelName = "prop_barrel_01a" -- change to your model
local modelHash = GetHashKey(modelName)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Wait(0)
end
print("Model loaded: " .. modelName .. " (" .. modelHash .. ")")
-- Release when done:
-- SetModelAsNoLongerNeeded(modelHash)Vehicle Models

adder
alpha
blade
ardent
asea
cogcabrio
baller
blistaReturns
VehicleReturns a vehicle handle.
Examples
Official
local heli = CreateVehicleServerSetter(`seasparrow`, 'heli', GetEntityCoords(GetPlayerPed(GetPlayers()[1])) + vector3(0, 0, 15), 0.0)
print(GetEntityCoords(heli)) -- should return correct coordinates