Jump to content

Disable automatic engine?


Cassandra

Recommended Posts

Posted

Didn't worked. Here's the code.

  
for k, v in pairs(getElementsByType("vehicle")) do 
  
    addEventHandler("onVehicleEnter", v,  
        function(player) 
         
            setVehicleEngineState(v, getElementData(vehicle, "vehicle.engine")) 
         
        end 
    ) 
     
    addEventHandler("onVehicleExit", v,  
        function(player) 
         
            setVehicleEngineState(v, getElementData(vehicle, "vehicle.engine")) 
         
        end 
    ) 
  
end 
  

Regards,

Cassandra - V:MP

Posted

That's because "v" and "vehicle" is not defined, also, I don't see why you need to loop all vehicles, you can just attach it to "root".

addEventHandler ( "onVehicleEnter", root, 
    function ( player ) 
        setVehicleEngineState ( source, getElementData ( source, "vehicle.engine" ) ) 
    end 
) 
  
addEventHandler ( "onVehicleExit", root, 
    function ( player ) 
        setVehicleEngineState ( source, getElementData ( source, "vehicle.engine" ) ) 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
That's because "v" and "vehicle" is not defined, also, I don't see why you need to loop all vehicles, you can just attach it to "root".
addEventHandler ( "onVehicleEnter", root, 
    function ( player ) 
        setVehicleEngineState ( source, getElementData ( source, "vehicle.engine" ) ) 
    end 
) 
  
addEventHandler ( "onVehicleExit", root, 
    function ( player ) 
        setVehicleEngineState ( source, getElementData ( source, "vehicle.engine" ) ) 
    end 
) 

Aaaahaaa. Silly mistake.

Edit: Thanks it works now.

Regards,

Cassandra - V:MP

Posted
playSound3D 

That's what you want?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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...