M MY Multiplayer: Wiki
Side
Kind

createVehicle

Server

Creates a vehicle on the server, seen by every player.

Also exists on the client, with its own implementation: createVehicle

vehicle|false createVehicle(string model, float x, y, z [, float rx, ry, rz = 0, 0, 0])

Parameters

NameTypeDescription
modelstringThe vehicle model's name, such as infernus. Case does not matter.
x, y, zfloatPosition in the world, or a vec3.
rx, ry, rzfloatRotation in degrees, or a vec3.default 0, 0, 0

Returns

The created vehicle, or false if the name is not a vehicle model's.

The vehicle goes under the dynamic element of the resource that created it.

Example

addCommandHandler("carro", function(player, command, model)
    local pos = getElementPosition(player)
    local vehicle = createVehicle(model or "infernus", pos.x + 3, pos.y, pos.z)
    if vehicle then
        warpPedIntoVehicle(player, vehicle)
    end
end)
Coming from MTAThe model is given by name, not by MTA's number. There are no number plate or variant arguments.

See also