setVehicleLightState
Shared
Breaks or repairs one or more lights of a vehicle.
bool setVehicleLightState(element vehicle, int|string|table light, int state)
Parameters
| Name | Type | Description |
|---|---|---|
| vehicle | element | The vehicle, or a parent element whose vehicles all change. |
| light | int|string|table | Which light: its number (0 front left, 1 front right, 2 rear right, 3 rear left), its frame name (headlight_l, headlight_r, taillight_r, taillight_l), a group (all, front_lights, rear_lights, left_lights, right_lights), -1 for all of them or a table of several. |
| state | int | The new state: 0 working, 1 broken. |
Returns
true if any light changed. false if the state is out of range or the vehicle lacks the light. On the server, also false when nothing changed.
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
addCommandHandler("quebrarfarois", function(player)
local vehicle = getPedOccupiedVehicle(player)
if vehicle then
setVehicleLightState(vehicle, "front_lights", 1)
end
end)