GetPedOccupiedVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(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...)
 
(Server and client now.)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Server client function}}
This function gets the [[vehicle]] that the ped is currently in, if any.
This function gets the [[vehicle]] that the ped is currently in, if any.



Revision as of 23:18, 18 January 2009

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