Difference between revisions of "IsVehicleTaxiLightOn"

From Multi Theft Auto: Wiki
Jump to: navigation, search
(fixed a typo)
(Example)
Line 16: Line 16:
  
 
==Example==
 
==Example==
 +
This example binds the 'o' key to a function that toggles the taxi's light on and off, if you're in a taxi.
 
<section name="Client" class="client" show="true">
 
<section name="Client" class="client" show="true">
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function myfunction()
+
function toggleTaxiLight()
 
local player = getLocalPlayer()
 
local player = getLocalPlayer()
 
local vehicle = getPedOccupiedVehicle(player)
 
local vehicle = getPedOccupiedVehicle(player)
Line 30: Line 31:
 
end
 
end
  
bind("o", "down", myfunction) -- binding the function
+
bind("o", "down", toggleTaxiLight) -- binding the function
  
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 20:32, 30 November 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

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

Click to collapse [-]
Client
function toggleTaxiLight()
	local player = getLocalPlayer()
	local vehicle = getPedOccupiedVehicle(player)
	if player == getVehicleOccupant(vehicle, 0) then -- if is a driver
		local lights = getVehicleTaxiLightOn(vehicle) -- getting vehicle lights state
		local id = getElementModel(vehicle) -- getting vehicle model
		if ((id == 420) or (id== 438)) then -- if is a taxi
			setVehicleTaxiLightOn(vehicle, not lights) -- switch lights
		end
	end	
end

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

See Also

FROM VERSION 1.6 r7485 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS