GetVehicleEngineState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:
This function returns a vehicle's engine state (on or off).
This function returns a vehicle's engine state (on or off).


{{New feature/item|3|1.0}}
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 30: Line 31:
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==Changelog==
*2008-06-23 - added ([http://bugs.mtasa.com/view.php?id=3544 issue 3544])
*2009-07-24 - fixed [http://bugs.mtasa.com/view.php?id=4687 issue 4687]
*2009-08-22 - fixed [http://bugs.mtasa.com/view.php?id=4851 issue 4851]


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}
[[Category:Changes_in_1.0]]

Revision as of 13:01, 22 November 2011

This function returns a vehicle's engine state (on or off).

{{{4}}}

Syntax

bool getVehicleEngineState ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle you wish to get the engine state of.

Returns

Returns true if the vehicle's engine is started, false otherwise.

Example

Click to collapse [-]
Serverside example

This example will switch the vehicle engine state with the command "/switchengine".

function switchEngine ( playerSource )
    local theVehicle = getPedOccupiedVehicle ( playerSource )

    -- Check if the player is in any vehicle and if he is the driver
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then
        local state = getVehicleEngineState ( theVehicle )
        setVehicleEngineState ( theVehicle, not state )
    end
end
addCommandHandler ( "switchengine", switchEngine )

Changelog

See Also