samt2497 Posted February 9, 2010 Posted February 9, 2010 i want to make all cars OFF by default and when a player is into car he will turn on please i want yours replys Ingame Nick [BOSS]Samt2497
TGW121 Posted February 9, 2010 Posted February 9, 2010 do you mean you want the car engines off then a user either gets in or hits a key to turn the engine on?
50p Posted February 9, 2010 Posted February 9, 2010 Look what I found by searching "engine state" https://forum.multitheftauto.com/viewtop ... te#p297850 I'm not sure if you need this but at least I use "uber, awesome, 1337 feature of the forum called Search". - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
samt2497 Posted February 9, 2010 Author Posted February 9, 2010 i only want all cars to initial state off when cars spawns they turned OFF automatic Ingame Nick [BOSS]Samt2497
Jason_Gregory Posted February 9, 2010 Posted February 9, 2010 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 ) Contact me if you need a Website / Signature ↑ / Mapuploadsystem (HTML5, JS, PHP, ASP.NET, MySQL / Sybase)
50p Posted February 9, 2010 Posted February 9, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Jason_Gregory Posted February 9, 2010 Posted February 9, 2010 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 ? Contact me if you need a Website / Signature ↑ / Mapuploadsystem (HTML5, JS, PHP, ASP.NET, MySQL / Sybase)
Jason_Gregory Posted February 10, 2010 Posted February 10, 2010 Another working way for turning all engine off is local allvehicles = getElementsByType("vehicle") for index,veh in ipairs(allvehicles ) do setVehicleEngineState ( veh, false ) end Contact me if you need a Website / Signature ↑ / Mapuploadsystem (HTML5, JS, PHP, ASP.NET, MySQL / Sybase)
Aibo Posted February 10, 2010 Posted February 10, 2010 its onVehicleRespawn, not OnVehicleRespawn. everything is case-sensitive. ?
Vercetti1010 Posted February 10, 2010 Posted February 10, 2010 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)
50p Posted February 10, 2010 Posted February 10, 2010 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 - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now