# setVehicleOverrideLights (Shared)

> Forces a vehicle's lights on or off, or hands the choice back to the game.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Vehicles
- **URL**: https://wiki.mymp.gg/en/setVehicleOverrideLights

## Syntax

```lua
bool setVehicleOverrideLights(element vehicle, int lights)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `vehicle` | `element` | The vehicle, or a parent element whose vehicles all change. |
| `lights` | `int` | 0 the game decides, 1 always off, 2 always on. |

## Returns

`true` if it changed. `false` if the value is out of range or was already set.

Given a parent element such as `root`, it applies to every vehicle below it, but the value returned is the element's own: `false` when it is not a vehicle.

## Example

```lua
addCommandHandler("farois", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if not vehicle then return end
    if getVehicleOverrideLights(vehicle) == 2 then
        setVehicleOverrideLights(vehicle, 1)
    else
        setVehicleOverrideLights(vehicle, 2)
    end
end)
```

## See also

- [getVehicleOverrideLights (Shared)](https://wiki.mymp.gg/en/getVehicleOverrideLights.md): Returns whether a vehicle's lights are forced on or off.
- [setVehicleFullBeam (Shared)](https://wiki.mymp.gg/en/setVehicleFullBeam.md): Turns a vehicle's high beams on or off.
- [setVehicleHeadLightColor (Shared)](https://wiki.mymp.gg/en/setVehicleHeadLightColor.md): Changes the colour of a vehicle's headlights.
