GetPedOccupiedVehicle

From Multi Theft Auto: Wiki
Revision as of 23:18, 18 January 2009 by Ccw (talk | contribs) (Server and client now.)
Jump to navigation Jump to search

This function gets the vehicle that the ped is currently in, if any.

Syntax

vehicle getPedOccupiedVehicle ( ped thePed )

Required Arguments

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

Returns

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

Example

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

function showVehicleName ( thePed )
	local theVehicle = getPedOccupiedVehicle ( thePed )
	if ( theVehicle ) then
		local vehicleName = getVehicleName ( theVehicle )
		outputChatBox ( "Vehicle name: " .. vehicleName, thePlayer )
	end
end
addCommandHandler ( "vehiclename", showVehicleName )

See Also