GetVehicleRotorState: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0161|1.6.0|22862|This function returns a vehicle's (plane or helicopter) rotor state (on or off).}} ==Syntax== <syntaxhighlight lang="lua"> bool getVehicleRotoState ( vehicle theVehicle ) </syntaxhighlight> {{OOP||vehicle:getRotorState|rotorState|setVehicleRotorState}} ===Required Arguments=== *'''theVehicle''': the vehicle you wish to get the engine state of. ===Returns=== Returns '''true''' if the vehicle's...")
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{New feature/item|3.0161|1.6.0|22862|This function returns a vehicle's (plane or helicopter) rotor state (on or off).}}
{{New feature/item|3.0161|1.6.0|22862|This function returns a vehicle's (plane or helicopter) rotor state (on or off).}}
{{Note|The function should not be confused with [[getVehicleEngineState]].}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool getVehicleRotoState ( vehicle theVehicle )
bool getVehicleRotorState ( vehicle theVehicle )
</syntaxhighlight>
</syntaxhighlight>


Line 17: Line 19:


==Example==
==Example==
{{Needs Example}}
<section name="Client" class="client" show="true">
This code adds a simple command that allows you to check a vehicle's rotor state keeping in mind you have to be in either a plane or helicopter.
<syntaxhighlight lang="lua">
function checkRotor()
    -- We need to check if the player is in a vehicle, and whether or not it is a plane or helicopter
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if (not vehicle or (getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane")) then
        outputChatBox("You are not in a plane or helicopter!", 255, 0, 0)
        return false
    end
    -- And now we show rotor state using a neat ternary expression
    local rotorState = getVehicleRotorState(vehicle)
    outputChatBox("Your vehicle's rotor is "..(rotorState and "spinning" or "stopped").."!", 0, 255, 0)
end
addCommandHandler("rotor", checkRotor)
</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Client vehicle functions}}
{{Client vehicle functions}}

Latest revision as of 22:04, 25 July 2025

ADDED/UPDATED IN VERSION 1.6.0 r22862:
This function returns a vehicle's (plane or helicopter) rotor state (on or off).
[[{{{image}}}|link=|]] Note: The function should not be confused with getVehicleEngineState.

Syntax

bool getVehicleRotorState ( vehicle theVehicle )


OOP Syntax Help! I don't understand this!

Method: vehicle:getRotorState(...)
Variable: .rotorState
Counterpart: setVehicleRotorState


Required Arguments

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

Returns

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

Example

Click to collapse [-]
Client

This code adds a simple command that allows you to check a vehicle's rotor state keeping in mind you have to be in either a plane or helicopter.

function checkRotor()
    -- We need to check if the player is in a vehicle, and whether or not it is a plane or helicopter
    local vehicle = getPedOccupiedVehicle(localPlayer)
    if (not vehicle or (getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane")) then
        outputChatBox("You are not in a plane or helicopter!", 255, 0, 0)
        return false
    end
    -- And now we show rotor state using a neat ternary expression
    local rotorState = getVehicleRotorState(vehicle)
    outputChatBox("Your vehicle's rotor is "..(rotorState and "spinning" or "stopped").."!", 0, 255, 0)
end
addCommandHandler("rotor", checkRotor)

See Also