- Documentation
- Shared functions
- setVehicleEngineState
Function
setVehicleEngineState
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.
statebooltrue= 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
getVehicleEngineStateChecks whether the vehicle's engine is running (set withsetVehicleEngineState; destroying the vehicle also turns the engine off).setWorldSpecialPropertyEnabledTurns a special world property on or off:hovercars,aircars,extrabunny,extrajump,randomfoliage,snipermoon,extraairresistance,underworldwarp,vehiclesunglare,coronaztest,watercreatures,burnflippedcars,fireballdestruct,roadsignstext,extendedwatercannons,tunnelweatherblend,ignorefirestate,flyingcomponents,vehicleburnexplosions,vehicle_engine_autostart.vehicle_engine_autostartreally works: turned off, a car engine does not start by itself when a driver gets in and must be turned on withsetVehicleEngineState.