getPedOccupiedVehicle | Multi Theft Auto: Wiki Skip to content

getPedOccupiedVehicle

Client-side
Server-side
Shared

Pair: warpPedIntoVehicle

This page is incomplete! Help wanted!

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


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

Syntax

getPedOccupiedVehicle ( )

Code Examples

server

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 )
else
outputChatBox ( "You do not have a Vehicle!", thePlayer, 255, 0, 0, true )
end
end
addCommandHandler ( "getcarname", showVehicleName )

See Also