SetVehicleEngineState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Added sections, minor changes, improved example)
m (Fixed section)
Line 4: Line 4:


==Syntax==
==Syntax==
<section name="Server and Client" class="both" show="true"/>
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setVehicleEngineState ( vehicle theVehicle, bool engineState )
bool setVehicleEngineState ( vehicle theVehicle, bool engineState )

Revision as of 21:21, 27 August 2007

This function turns a vehicle's engine on or off.

Syntax

Click to collapse [-]
Server and Client
bool setVehicleEngineState ( vehicle theVehicle, bool engineState )

Required Arguments

  • theVehicle: The vehicle you wish to change the engine state of.
  • engineState: A boolean value representing whether the engine will be turned on (true) or off (false).

Returns

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

Example

Click to collapse [-]
Serverside example

This example will turn off a vehicle's engine when the driver gets out of the car.

function turnEngineOff ( theVehicle, leftSeat, jackerPlayer )
    -- if it's the driver who got out, and he was not jacked,
    if leftSeat == 0 and not jackerPlayer then
        -- turn off the engine
        setVehicleEngineState ( theVehicle, false )
    end
end
-- add 'turnEngineOff' as a handler for "onPlayerExitVehicle"
addEventHandler ( "onPlayerExitVehicle", getRootElement ( ), turnEngineOff )

</section>

See Also