GetVehicleEngineState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 4: Line 4:


==Syntax==
==Syntax==
<section name="Server and Client" class="both" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool getVehicleEngineState ( vehicle theVehicle )
bool getVehicleEngineState ( vehicle theVehicle )
Line 14: Line 13:
===Returns===
===Returns===
Returns '''true''' if the vehicle's engine is started, '''false''' otherwise.
Returns '''true''' if the vehicle's engine is started, '''false''' otherwise.
</section>


==Example==
==Example==

Revision as of 20:55, 18 July 2010

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

Syntax

bool getVehicleEngineState ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle you wish to change 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 )

See Also