GetPlayerOccupiedVehicle

From Multi Theft Auto: Wiki
Revision as of 11:55, 7 August 2007 by Driver2 (talk | contribs)
Jump to navigation Jump to search

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

Syntax

Click to collapse [-]
Server
vehicle getPlayerOccupiedVehicle ( player thePlayer )

Required Arguments

  • thePlayer: The player whose vehicle you're looking up.

Returns

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

Click to expand [+]
Client

Example

This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command.

Click to collapse [-]
Server
function showVehicleName(player)
	local vehicle = getPlayerOccupiedVehicle(player)
	if (vehicle ~= false) then
		local vehicleName = getVehicleName(vehicle)
		outputChatBox("Vehicle name: "..vehicleName,player)
	end
end
addCommandHandler("vehicleName",showVehicleName)

This example outputs the vehicle name of the vehicle if the player is currently occupying one, when he enters the 'vehicleName' command. <section name="Client" class="client">

function showVehicleName()

        local vehicle = getPlayerOccupiedVehicle()
        if (vehicle ~= false) then
                local vehicleName = getVehicleName(vehicle)
                outputChatBox("Vehicle name: "..vehicleName,player)
        end
end
addCommandHandler("vehicleName",showVehicleName)

See Also

Shared