GetVehicleEngineState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
(OOP)
Line 8: Line 8:
bool getVehicleEngineState ( vehicle theVehicle )
bool getVehicleEngineState ( vehicle theVehicle )
</syntaxhighlight>
</syntaxhighlight>
 
{{OOP||[[vehicle]]:getEngineState|engineState|setVehicleEngineState}}
===Required Arguments===
===Required Arguments===
*'''theVehicle''': The [[vehicle]] you wish to get the engine state of.
*'''theVehicle''': the [[vehicle]] you wish to get the engine state of.


===Returns===
===Returns===

Revision as of 15:59, 13 October 2014

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

{{{4}}}

Syntax

bool getVehicleEngineState ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getEngineState(...)
Variable: .engineState
Counterpart: setVehicleEngineState


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 )

See Also