setVehicleOverrideLights | Multi Theft Auto: Wiki Skip to content

setVehicleOverrideLights

Client-side
Server-side
Shared

Pair: getVehicleOverrideLights

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function changes the light overriding setting on a vehicle.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:setOverrideLights(...)
  • Variable: .overrideLights

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 the state of the lights: 0 : No override, lights are set to default. 1 : Lights are forced off. 2 : Lights are forced on.

Returns

  • bool: value

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

Code Examples

shared

This example will toggle the car lights on and off for a player's vehicle by using a "vehiclelights" command.

function consoleVehicleLights ( source )
if isPedInVehicle(source) then -- checks is the player in vehicle if yes, then:
playerVehicle = getPedOccupiedVehicle ( source ) -- get the player's vehicle
if ( playerVehicle ) then -- if he was in one
if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then -- if the current state isn't 'force on'
setVehicleOverrideLights ( playerVehicle, 2 ) -- force the lights on
else
setVehicleOverrideLights ( playerVehicle, 1 ) -- otherwise, force the lights off
end
end
end
end
addCommandHandler ( "vehiclelights", consoleVehicleLights )

See Also

Vehicle Functions