ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Shared functions
  3. setVehicleEngineState

Function

setVehicleEngineState

Server and clientVehiclesIdentical to MTA:SA

Turns a vehicle's engine on or off for every player. With the engine off the vehicle does not drive even when the driver presses the throttle (it can only roll). By default the engine starts by itself when a driver gets in; after setWorldSpecialPropertyEnabled("vehicle_engine_autostart", false) it does not, and an RP server can build its own ignition on a key or command.

Syntax

bool setVehicleEngineState(vehicle vehicle, bool state)

Arguments

vehiclevehicle
The vehicle.
statebool
true = engine running, false = off.

Returns

true on success.

Example

addCommandHandler("silnik", function(player)
    local vehicle = getPedOccupiedVehicle(player)
    if vehicle and getVehicleController(vehicle) == player then
        setVehicleEngineState(vehicle, not getVehicleEngineState(vehicle))
    end
end)

See also