IsTrainChainEngine: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Server client function}} __NOTOC__ {{New items|3.0140|1.4| This function checks if a train is a chain engine (moves the rest of the chain's trains) or no...") |
mNo edit summary |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Client function}} | ||
__NOTOC__ | __NOTOC__ | ||
{{New items|3.0140|1.4| | {{New items|3.0140|1.4| | ||
This function checks if a [[Element/Vehicle|train]] is a chain engine (moves the rest of the chain's | This function checks if a [[Element/Vehicle|train]] is a chain engine (moves the rest of the chain's carriages) or not. | ||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool isTrainChainEngine( vehicle theTrain ) | bool isTrainChainEngine ( vehicle theTrain ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{New feature/item|3.0141|1.4.1|6946|{{OOP||[[Element/Vehicle|vehicle]]:isTrainChainEngine|chainEngine}}}} | |||
===Arguments=== | ===Arguments=== | ||
*'''theTrain:''' a [[Element/Vehicle|train]] to check if it's a chain engine or not. | *'''theTrain:''' a [[Element/Vehicle|train]] to check if it's a chain engine or not. | ||
===Returns=== | ===Returns=== | ||
* ''true'' if a [[Element/Vehicle|train]] was passed to the function and if it's a chain engine. | |||
* ''false'' otherwise. | |||
==Example== | ==Example== | ||
The next code snippet adds a /isthistrainachainengine, which checks if the train occupied by the player who types the command is a chain engine or not. | The next code snippet adds a /isthistrainachainengine, which checks if the train occupied by the player who types the command is a chain engine or not. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function checkTrainChainEngine( | function checkTrainChainEngine() | ||
if isPedInVehicle(localPlayer) then | |||
local train = getPedOccupiedVehicle(localPlayer) | |||
if getVehicleType(train) == "Train" then | |||
outputChatBox("Your train " .. (isTrainChainEngine(train) and "is" or "isn't") .. " a chain engine.", 255, 128, 0) | |||
else | |||
outputChatBox("You need to be in a train to use this command.", 255, 0, 0) | |||
end | |||
end | |||
end | end | ||
addCommandHandler("isthistrainachainengine", checkTrainChainEngine) | addCommandHandler("isthistrainachainengine", checkTrainChainEngine) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See also== | ==See also== | ||
{{Vehicle functions}} | {{Vehicle functions}} | ||
[[ru:IsTrainChainEngine]] |
Latest revision as of 23:13, 2 August 2016
This function checks if a train is a chain engine (moves the rest of the chain's carriages) or not.
Syntax
bool isTrainChainEngine ( vehicle theTrain )
OOP Syntax Help! I don't understand this!
- Method: vehicle:isTrainChainEngine(...)
- Variable: .chainEngine
Arguments
- theTrain: a train to check if it's a chain engine or not.
Returns
- true if a train was passed to the function and if it's a chain engine.
- false otherwise.
Example
The next code snippet adds a /isthistrainachainengine, which checks if the train occupied by the player who types the command is a chain engine or not.
function checkTrainChainEngine() if isPedInVehicle(localPlayer) then local train = getPedOccupiedVehicle(localPlayer) if getVehicleType(train) == "Train" then outputChatBox("Your train " .. (isTrainChainEngine(train) and "is" or "isn't") .. " a chain engine.", 255, 128, 0) else outputChatBox("You need to be in a train to use this command.", 255, 0, 0) end end end addCommandHandler("isthistrainachainengine", checkTrainChainEngine)
See also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- 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
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates