SetVehicleTaxiLightOn: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Removed needs checking, according to mantis this issue is resolved.)
No edit summary
Line 7: Line 7:
bool setVehicleTaxiLightOn ( vehicle taxi, bool LightState )               
bool setVehicleTaxiLightOn ( vehicle taxi, bool LightState )               
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:setTaxiLightOn|taxiLightOn|isVehicleTaxiLightOn}}
===Required Arguments===  
===Required Arguments===  
*'''taxi:''' The vehicle element of the taxi that you wish to turn the light on.
*'''taxi:''' The vehicle element of the taxi that you wish to turn the light on.

Revision as of 22:18, 18 December 2014

This function will set the taxi light on in a taxi (vehicle ID's 420 and 438)

Syntax

bool setVehicleTaxiLightOn ( vehicle taxi, bool LightState )              

OOP Syntax Help! I don't understand this!

Method: vehicle:setTaxiLightOn(...)
Variable: .taxiLightOn
Counterpart: isVehicleTaxiLightOn


Required Arguments

  • taxi: The vehicle element of the taxi that you wish to turn the light on.
  • LightState: whether the light is on. True for on, False for off.

Returns

Returns true if the state was successfully set, false otherwise.

Example

This example sets the taxi light on when the player presses "o" in a taxi.

addEventHandler ( "onPlayerJoin" , getRootElement ( ) , 
function ( )
  bindKey ( source , "o", "down", 
    function ( thePlayer )
      if ( isPedInVehicle ( thePlayer ) ) then --is in vehicle or not?
        local vehicle = getPedOccupiedVehicle ( thePlayer ) --getting player's occupied vehicle
        if ( getVehicleController ( vehicle ) == thePlayer ) then --is driver or not?
          local id = getElementModel ( vehicle ) --getting vehicle's model
          if ( ( id == 420 ) or ( id == 438 ) ) then --is a taxi?
            setVehicleTaxiLightOn ( vehicle, not isVehicleTaxiLightOn ( vehicle ) ) --changing taxi light on/off
          end
        end	
      end
   end)
end )

See Also