ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. warpPedIntoVehicle

Function

warpPedIntoVehicle

ServerPedsIdentical to MTA:SA

Instantly puts a player or an NPC into the chosen vehicle seat, without walking up and without the get-in animation. If the ped was in another car, it is taken out of it first. When the chosen seat is occupied by someone else, nothing happens and the function returns false. The player's game receives the order immediately, and the server blocks the player from getting out on their own for 3 seconds so the warp is not undone. An NPC in a vehicle always stays seated: while it is in the car, its body has no collision (only bullets hit it), walking and turning wait until it leaves the car, and if the game takes it out of the seat, the client puts it back at once.

Syntax

bool warpPedIntoVehicle(ped ped, vehicle vehicle [, int seat = 0])

Arguments

pedped
The player or NPC to put in.
vehiclevehicle
The target vehicle.
seatint, optional = 0
Seat 0-8: 0 = driver, 1 = front passenger, 2-3 = rear, higher ones only in vehicles that have them.

Returns

true on success, false when the seat is taken or an argument is wrong.

Example

addCommandHandler("auto", function(player)
    local x, y, z = getElementPosition(player)
    local car = createVehicle(411, x + 3, y, z)
    warpPedIntoVehicle(player, car, 0)
end)

See also