Difference between revisions of "IsVehicleTaxiLightOn"

From Multi Theft Auto: Wiki
Jump to: navigation, search
m
(Example)
Line 23: Line 23:
 
local theVehicle = getPedOccupiedVehicle(thePlayer)
 
local theVehicle = getPedOccupiedVehicle(thePlayer)
 
if thePlayer == getVehicleOccupant(theVehicle, 0) then -- if is a driver
 
if thePlayer == getVehicleOccupant(theVehicle, 0) then -- if is a driver
local lights = getVehicleTaxiLightOn(theVehicle) -- getting vehicle lights state
 
 
local id = getElementModel(theVehicle) -- getting vehicle model
 
local id = getElementModel(theVehicle) -- getting vehicle model
 
if ((id == 420) or (id== 438)) then -- if is a taxi
 
if ((id == 420) or (id== 438)) then -- if is a taxi
 +
local lights = isVehicleTaxiLightOn(theVehicle) -- getting vehicle lights state
 
setVehicleTaxiLightOn(theVehicle, not lights) -- switch lights
 
setVehicleTaxiLightOn(theVehicle, not lights) -- switch lights
 
end
 
end

Revision as of 12:16, 2 December 2009

This function will get the taxi light state of a taxi (vehicle ID's 420 and 438)

Syntax

bool isVehicleTaxiLightOn ( vehicle taxi )              

Required Arguments

  • taxi: The vehicle element of the taxi that you wish to get the light state of.

Returns

Returns true if the light is on, false otherwise.

Example

Click to collapse [-]
Client

This example binds the 'o' key to a function that toggles the taxi's light on and off, if you're in a taxi.

function toggleTaxiLight()
	local thePlayer = getLocalPlayer()
	local theVehicle = getPedOccupiedVehicle(thePlayer)
	if thePlayer == getVehicleOccupant(theVehicle, 0) then -- if is a driver
		local id = getElementModel(theVehicle) -- getting vehicle model
		if ((id == 420) or (id== 438)) then -- if is a taxi
			local lights = isVehicleTaxiLightOn(theVehicle) -- getting vehicle lights state
			setVehicleTaxiLightOn(theVehicle, not lights) -- switch lights
		end
	end	
end

bindKey("o", "down", toggleTaxiLight) -- binding the function

See Also

FROM VERSION 1.6 r7485 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS