GetVehicleLightState: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua>
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)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{Template:VehicleFunctions}}
{{Template:VehicleFunctions}}

Latest revision as of 16:06, 27 May 2021

GetVehicleLightState

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Get the vehicle's light state.

Syntax

GetVehicleLightState(vehicle)

Parameters

  • vehicle
    The vehicle identifier.

Return Value

  • Returns true on success.

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