setVehicleEngineState | Multi Theft Auto: Wiki Skip to content

setVehicleEngineState

Client-side
Server-side
Shared

Pair: getVehicleEngineState

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function turns a vehicle's engine on or off. Note that the engine will always be turned on when someone enters the driver seat, unless you override that behaviour with scripts.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:setEngineState(...)
  • Variable: .engineState

Syntax

bool setVehicleEngineState ( vehicle theVehicle, bool engineState )
Required Arguments
  • theVehicle: The vehicle you wish to change the engine state of.
  • engineState: A boolean value representing whether the engine will be turned on ( true ) or off ( false ).

Returns

  • bool: value

Returns true if the vehicle's engine state was successfully changed, false otherwise.

Code Examples

shared

This example lets the driver toggle vehicle engine on/off.

function toggleEngine()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle and getVehicleController(vehicle) == localPlayer then
setVehicleEngineState(vehicle, not getVehicleEngineState(vehicle))
end
end
addCommandHandler("engine", toggleEngine)

See Also

Vehicle Functions