From Multi Theft Auto: Wiki
Revision as of 17:54, 7 October 2018 by Surge (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This function gets the vehicle that the ped is currently in or is trying to enter, if any.


vehicle getPedOccupiedVehicle ( ped thePed )

OOP Syntax Help! I don't understand this!

Note: Set the variable to nil to execute removePedFromVehicle
Method: ped:getOccupiedVehicle(...)
Variable: .vehicle
Counterpart: warpPedIntoVehicle

Required Arguments

  • thePed: The ped whose vehicle you're looking up.


Returns the vehicle that the specified ped is in, or false if the ped is not in a vehicle or is an invalid ped.


When a ped enters the 'getcarname' command and is currently in a vehicle, this example outputs the name of the vehicle.

function showVehicleName ( thePlayer )
   local theVehicle = getPedOccupiedVehicle ( thePlayer )
   if theVehicle then
      outputChatBox ( "Name of the Vehicle: " .. getVehicleName ( theVehicle ), thePlayer )
      outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true )
addCommandHandler ( "getcarname", showVehicleName )

See Also