GetVehicleEngineState: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 11: Line 11:


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua>
AddCommand("engine", function(playerid)
    local vehicle = GetPlayerOccupiedVehicle(playerid)
    if vehicle == 0 then
        return AddPlayerChat(playerid, "You must be in a vehicle!")
    end
 
    local state = not GetVehicleEngineState(vehicle)
    SetVehicleEngineState(vehicle, state)
    return AddPlayerChat(playerid, "Vehicle engine state changed to: " .. (state and "on" or "off") .. "!")
end)
</syntaxhighlight>


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

Revision as of 16:08, 27 May 2021

GetVehicleEngineState

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

Description

Get the vehicle's engine state.

Syntax

GetVehicleEngineState(vehicle)

Parameters

  • vehicle
    The vehicle identifier.

Return Value

  • Returns true if on.

Example

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

    local state = not GetVehicleEngineState(vehicle)
    SetVehicleEngineState(vehicle, state)
    return AddPlayerChat(playerid, "Vehicle engine state changed to: " .. (state and "on" or "off") .. "!")
end)

See also