SetVehicleLightEnabled: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|SetVehicleLightEnabled(vehicle, enabled)}} {{FuncParameters}} {{FuncParam|vehicle|__EDIT_ME__}} {{..."
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|This function toggles the vehicle's lights.}}


{{FuncSyntax|SetVehicleLightEnabled(vehicle, enabled)}}
{{FuncSyntax|SetVehicleLightEnabled(vehicle, enabled)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|vehicle|__EDIT_ME__}}
{{FuncParam|vehicle|The vehicle identifier.}}
{{FuncParam|enabled|__EDIT_ME__}}
{{FuncParam|enabled|The boolean status}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|This function returns '''?'''.}}


== 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}}
__EDIT_ME__
{{Template:VehicleFunctions}}

Latest revision as of 16:05, 27 May 2021

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