IsVehicleTaxiLightOn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 20: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function toggleTaxiLight()
function toggleTaxiLight()
local player = getLocalPlayer()
local gamer = getLocalPlayer()
local vehicle = getPedOccupiedVehicle(player)
local car = getPedOccupiedVehicle(gamer)
if player == getVehicleOccupant(vehicle, 0) then -- if is a driver
if gamer == getVehicleOccupant(car, 0) then -- if is a driver
local lights = getVehicleTaxiLightOn(vehicle) -- getting vehicle lights state
local lights = getVehicleTaxiLightOn(car) -- getting vehicle lights state
local id = getElementModel(vehicle) -- getting vehicle model
local id = getElementModel(car) -- 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
setVehicleTaxiLightOn(vehicle, not lights) -- switch lights
setVehicleTaxiLightOn(car, not lights) -- switch lights
end
end
end
end

Revision as of 17:01, 1 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 gamer = getLocalPlayer()
	local car = getPedOccupiedVehicle(gamer)
	if gamer == getVehicleOccupant(car, 0) then -- if is a driver
		local lights = getVehicleTaxiLightOn(car) -- getting vehicle lights state
		local id = getElementModel(car) -- getting vehicle model
		if ((id == 420) or (id== 438)) then -- if is a taxi
			setVehicleTaxiLightOn(car, not lights) -- switch lights
		end
	end	
end

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

See Also