GetVehicleRotorState: Difference between revisions
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 | bool getVehicleRotorState ( vehicle theVehicle ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 17: | Line 19: | ||
==Example== | ==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
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 [-]
ClientThis 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
- areVehicleLightsOn
- getHeliBladeCollisionsEnabled
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponents
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleDummyPosition
- getVehicleGravity
- getVehicleLandingGearDown
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleOnGround
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHeliBladeCollisionsEnabled
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleLandingGearDown
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleWheelScale
- setVehicleWheelStates
- setVehicleWindowOpen
- Shared
- addVehicleUpgrade
- addVehicleSirens
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- setVehicleNitroActivated
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- removeVehicleSirens
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates