warpPedIntoVehicle | Multi Theft Auto: Wiki Skip to content

warpPedIntoVehicle

Client-side
Server-side
Shared

Pair: getPedOccupiedVehicle

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function is used to warp or force a ped into a vehicle. There are no animations involved when this happens.

Important

If you used setElementPosition to spawn the ped / player , this function will not work and returns false .

OOP Syntax Help! I don't understand this!

  • Note: Set the variable to nil to executeremovePedFromVehicle

  • Method:ped:warpIntoVehicle(...)
  • Variable: .vehicle

Syntax

bool warpPedIntoVehicle ( ped thePed, vehicle theVehicle, [ int seat = 0 ] )
Required Arguments
  • thePed: The ped which you wish to force inside the vehicle
  • theVehicle: The vehicle you wish to force the ped into
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • seat (default: 0): An integer representing the seat ID. 0: Front-left 1: Front-right 2: Rear-left 3: Rear-right

Returns

  • bool: value

Returns true if the operation is successful, false otherwise.

Code Examples

shared

This example creates a vehicle and warps a ped inside immediately.

function setupForRace ( )
local RacerPed = createPed ( 252, 0, 0, 3 )
local RaceVehicle = createVehicle ( 411, 4, 0, 3 ) -- create a vehicle.
warpPedIntoVehicle ( RacerPed, RaceVehicle ) -- warp the ped straight into the vehicle
end
addCommandHandler ( "startrace", setupForRace ) -- add a command to start race

Issues

ID Description
475 Network trouble when calling warpPedIntoVehicle on resourceStart

See Also