SetVehicleLightEnabled

From Onset Developer Wiki
SetVehicleLightEnabled

Type: Function
Context: Server
Introduced: v1.0

Description

This function toggles the vehicle's lights.

Syntax

SetVehicleLightEnabled(vehicle, enabled)

Parameters

  • vehicle
    The vehicle identifier.
  • enabled
    The boolean status

Return Value

  • This function returns ?.

Example

AddCommand("lights", function(playerid)
    local vehicle = GetPlayerOccupiedVehicle(playerid)
    if vehicle == 0 then
        return AddPlayerChat(playerid, "You must be in a vehicle!")
    end

    local state = not GetVehicleLightEnabled(vehicle)
    SetVehicleLightEnabled(vehicle, state)
    return AddPlayerChat(playerid, "Vehicle headlights changed to: " .. (state and "on" or "off") .. "!")
end)

See also