SetVehicleEngineState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 14: Line 14:
This example will disallow the use of the engine in any vehicle
This example will disallow the use of the engine in any vehicle
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "onPlayerEnterVehicle", "onPlayerEnterVehicle" )
addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
   if ( getPlayerOccupiedVehicleSeat ( source ) == 0 ) then -- if they're getting into the driver seat
   if ( seat == 0 ) then -- if they're getting into the driver seat
     setVehicleEngineState ( theVehicle, false ) -- turn off the engine
     setVehicleEngineState ( theVehicle, false ) -- turn off the engine
   end
   end

Revision as of 11:36, 19 July 2006

This function changes the on/off state of a vehicle's engine

Syntax

bool setVehicleEngineState ( vehicle theVehicle, bool EngineOn )

Required Arguments

  • theVehicle: The vehicle you wish to change the engine state of.
  • EngineOn: A boolean value representing whether or not the engine will be turnt on or off.

Returns

Returns 'true' if the vehicle's engine state was successfully changed, 'false' otherwise.

Example

This example will disallow the use of the engine in any vehicle

addEventHandler ( "onPlayerEnterVehicle", root, "onPlayerEnterVehicle" )
function onPlayerEnterVehicle ( theVehicle, seat, jacked )
  if ( seat == 0 ) then -- if they're getting into the driver seat
    setVehicleEngineState ( theVehicle, false ) -- turn off the engine
  end
end

See Also