- Documentation
- Shared functions
- setVehicleOverrideLights
Function
setVehicleOverrideLights
Forces the state of a vehicle's lights for every player. In Trilogy Hub the game does not switch the lights on at dusk by itself, so the headlights only shine after setting 2. Single lamps (brake, reverse, indicators) are set with setVehicleLampState.
Syntax
bool setVehicleOverrideLights(vehicle vehicle, int state)Arguments
vehiclevehicle- The vehicle.
stateint- 0 = no override (lights off), 1 = always off, 2 = always on.
Returns
true on success, false for a value outside 0-2.
Example
addCommandHandler("swiatla", function(player)
local vehicle = getPedOccupiedVehicle(player)
if vehicle and getVehicleController(vehicle) == player then
setVehicleOverrideLights(vehicle, getVehicleOverrideLights(vehicle) == 2 and 1 or 2)
end
end)
Notes
Client. In a client script the lights apply for this player only, until the server sets them for this vehicle.
See also
getVehicleOverrideLightsReturns the forced light state: 0 no override, 1 off, 2 on.areVehicleLightsOnChecks whether the vehicle's headlights are on, i.e. whethersetVehicleOverrideLights(vehicle, 2)was set. Works on both sides.setVehicleLampStateTurns one lamp (or a group of lamps) of a vehicle on, off or back to game control, for every player. This lets a script e.g. light the brake lamps when braking, the reverse lamps, or leave a single headlight working. The'auto'state means the lamp works as usual in the game. An indicator set to'on'shines steadily; blinking comes fromsetVehicleIndicators. Game cars have no reverse lamps or separate indicators (the front shines orange, the rear uses the red lens); custom models fromengineReplaceModelhave all lamps.