GetPedOccupiedVehicle

From Multi Theft Auto: Wiki
Revision as of 17:58, 30 March 2008 by Arc (talk | contribs) (New page: __NOTOC__ {{Client function}} This function gets the vehicle that the ped is currently in, if any. ==Syntax== <syntaxhighlight lang="lua">vehicle getPedOccupiedVehicle ( ped thePed )</syntaxhighlight> ===Requ...)
(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, 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