- Documentation
- Server functions
- warpPedIntoVehicle
Function
warpPedIntoVehicle
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
removePedFromVehicleInstantly takes a player or an NPC out of a vehicle and places them next to it, without the get-out animation. It firesonPlayerVehicleExitjust like a normal exit and blocks the player from getting back in for 3 seconds so the game does not put them back. Returnsfalsewhen the ped is not in a vehicle.setPedEnterVehicleTells a ped to get into a vehicle the normal way, walking up and playing the door animation. On the client it only works for the local player: the player walks to a vehicle within 10 m and gets in (other peds givefalse). On the server it records the ped's task and sends every client theonClientPedEnterRequestevent (ped, vehicle, seat), which a client script can handle; the ped itself does not walk up yet on the server.getVehicleMaxPassengersReturns the number of passenger seats of a vehicle or model (not counting the driver): e.g. 1 for a two-seater, 3 for a saloon. The data comes from the game, so the server only knows it once a client reports it (usually after the model first appears for a player); before that it returnsfalse.