Jump to content

Turn OFF all cars with setvehicleenginestate


samt2497

Recommended Posts

More than just simple.

Add a Handler for the VehicleRespawn and set the EngineState...

function onVehicleRespawn ( theVehicle )
setVehicleEngineState ( theVehicle, false )
end
addEventHandler ( "OnVehicleRespawn", getRootElement(), onVehicleRespawn )

Jason_Gregory, if you want to help, make sure it works or be 99.9% sure it works. In a 4 lines script you made 2 mistakes. I'll let you find them.

Link to comment

lemme take a look...

function onVehicleRespawn ( exploded )
setVehicleEngineState ( source, false )
end
addEventHandler ( "OnVehicleRespawn", getRootElement(), onVehicleRespawn )

function onVehicleRespawn ( exploded )
if ( exploded )then
setVehicleEngineState ( source, false )
end
end
addEventHandler ( "OnVehicleRespawn", getRootElement(), onVehicleRespawn )

better ?

Link to comment

By default, when a car is created, the engine should be off. However, when a vehicle is entered, the cars engine will turn on by itself. To counteract this, the game must detect when people enter, exit, or die in a vehicle in order to force the engine to stop. Most vehicles will not operate when the engine is off, but helicopters, planes, bikes, etc. will still work even with the engine being off. I don't think I need to mention bicycles though. Anyway, the code below should take care of your problem. Make sure you test it before you put it on your server though.

function carOffEnter(player,seat,jacked)
if (seat == 0) and (jacked == false) then
setVehicleEngineState(source,false)
end
end
 
function carOffExit(player,seat,jacked)
if (seat == 0) and (jacked == false) then
setVehicleEngineState(source,false)
end
end
 
function carOffDead(totalAmmo,killer,killerWeapon,bodypart,stealth)
local car = getPedOccupiedVehicle(source)
if (car ~= false) then
setVehicleEngineState(car,false)
end
end
 
addEventHandler("onVehicleEnter",getRootElement(),carOffEnter)
addEventHandler("onVehicleStartExit",getRootElement(),carOffExit)
addEventHandler("onPlayerWasted",getRootElement(),carOffDead)

Link to comment
By default, when a car is created, the engine should be off. However, when a vehicle is entered, the cars engine will turn on by itself. To counteract this, the game must detect when people enter, exit, or die in a vehicle in order to force the engine to stop. Most vehicles will not operate when the engine is off, but helicopters, planes, bikes, etc. will still work even with the engine being off. I don't think I need to mention bicycles though. Anyway, the code below should take care of your problem. Make sure you test it before you put it on your server though.

....

You can try to change helicopter's rotor speed with https://wiki.multitheftauto.com/wiki/Set ... RotorSpeed

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...