- Documentation
- Server functions
- setVehicleLampState
Function
setVehicleLampState
Turns 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 from setVehicleIndicators. Game cars have no reverse lamps or separate indicators (the front shines orange, the rear uses the red lens); custom models from engineReplaceModel have all lamps.
Syntax
bool setVehicleLampState(vehicle vehicle, string/int lamp [, string/bool state = 'auto'])Arguments
vehiclevehicle- The vehicle.
lampstring/int- Lamp name:
front_left,front_right,rear_left,rear_right,brake_left,brake_right,reverse_left,reverse_right,indicator_front_left,indicator_front_right,indicator_rear_left,indicator_rear_right; group:front,rear,brake,reverse,indicators,indicator_left,indicator_right,left,right,all; or a number 0-11 in this order. statestring/bool, optional = 'auto''on'/true= lit,'off'/false= off,'auto'/nil= as in the game.
Returns
true on success, false for a bad name or state.
Example
addCommandHandler("cofanie", function(player)
local vehicle = getPedOccupiedVehicle(player)
if vehicle then setVehicleLampState(vehicle, "reverse", "on") end
end)
See also
getVehicleLampStateReturns the state of a lamp or lamp group set withsetVehicleLampState:'auto','on'or'off'. When the lamps in a group differ, it returns'mixed'.getVehicleLampNamesReturns the names of all twelve lamps accepted bysetVehicleLampState, in the order of numbers 0-11 (fromfront_lefttoindicator_rear_right). Groups (front,all…) are not in the list.resetVehicleLampStatesReturns all of a vehicle's lamps to'auto', i.e. working as in the game. Clears everything set withsetVehicleLampState.setVehicleIndicatorsTurns on a vehicle's indicators, which blink for every player. On vehicles with their own model (engineReplaceModel) the lamps marked in the model with SA indicator colours blink. Game cars have no separate indicators, so the front blinks orange and the rear uses the red lens. A single lamp is set withsetVehicleLampState.