SetVehicleOverrideLights: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 16: Line 16:
addCommandHandler ( "vehiclelights", "vehicleLights" )
addCommandHandler ( "vehiclelights", "vehicleLights" )
function vehicleLights ( source )
function vehicleLights ( source )
   vehicle = getPlayerOccupiedVehicle ( source )
   vehicle = getPlayerOccupiedVehicle ( source ) -- get the player's vehicle
   if ( vehicle ) then
   if ( vehicle ) then -- if he was in one
     if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then
     if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then -- if the current state isnt 'force on'
       setVehicleOverrideLights ( vehicle, 2 )
       setVehicleOverrideLights ( vehicle, 2 ) -- force the lights on
     else
     else
       setVehicleOverrideLights ( vehicle, 1 )
       setVehicleOverrideLights ( vehicle, 1 ) -- otherwise, force the lights off
     end
     end
   end
   end

Revision as of 15:04, 30 June 2006

This function changes the overriding lights setting on a vehicle, possible values are: 1 (No override), 2 (Force off), 3 (Force on)

Syntax

bool setVehicleOverrideLights ( vehicle theVehicle, int Value )

Required Arguments

  • theVehicle: The vehicle you wish to change the override lights setting of.
  • Value: A whole number representing 1 of the 3 settings (0,1,2)

Returns

Returns 'true' if the vehicle's lights settings was changed. Otherwise 'false'.

Example

This example will toggle the car lights on and off for a player's vehicle

addCommandHandler ( "vehiclelights", "vehicleLights" )
function vehicleLights ( source )
  vehicle = getPlayerOccupiedVehicle ( source ) -- get the player's vehicle
  if ( vehicle ) then -- if he was in one
    if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then -- if the current state isnt 'force on'
      setVehicleOverrideLights ( vehicle, 2 ) -- force the lights on
    else
      setVehicleOverrideLights ( vehicle, 1 ) -- otherwise, force the lights off
    end
  end
end

See Also