GetVehicleEngineState

From Onset Developer Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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)
    if state == true then
        StopVehicleEngine(vehicle)
    else
        StartVehicleEngine(vehicle)
    end

    return AddPlayerChat(playerid, "Vehicle engine state changed to: " .. (state and "on" or "off") .. "!")
end)

See also