GetTrainDirection
From Multi Theft Auto: Wiki
Gets the direction in which a train is driving (clockwise or counterclockwise).
Syntax
bool getTrainDirection ( vehicle train )
Required Arguments
- train: the train of which to get the driving direction.
Returns
Returns true if the train is driving clockwise on the train track, false if it is going counterclockwise or a failure occured.
Example
This example outputs to the player the direction the train they're driving is travelling.
function trainDir(thePlayer,command) if (isPedInVehicle(thePlayer)) then -- Check if they're even in a vehicle. if (getVehicleType(getPedOccupiedVehicle(thePlayer)) == "Train") then -- Check if they're in a train. local direction = getTrainDirection(getPedOccupiedVehicle(thePlayer)) -- Get the train's direction. if (direction) then outputChatBox("You're driving clockwise.",thePlayer,255,255,0) -- Output that they're driving clockwise. else outputChatBox("You're driving anti-clockwise.",thePlayer,255,255,0) -- Output that they're driving anti-clockwise. end else outputChatBox("You must be in a train to use this command.",thePlayer,255,0,0) -- Output that they're not in a train. end else outputChatBox("You must be in a train to use this command.",thePlayer,255,0,0) -- Output that they're not in a vehicle. end end addCommandHandler("direction",trainDir)
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorState
- getVehicleEngineState
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleName
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehicleSirensOn
- getVehiclesOfType
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurnVelocity
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgrades
- getVehicleUpgradeSlotName
- getVehicleWheelStates
- getVehicleDoorOpenRatio
- getVehicleHandling
- getModelHandling
- getOriginalHandling
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- removeVehicleUpgrade
- resetVehicleExplosionTime
- resetVehicleIdleTime
- respawnVehicle
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleIdleRespawnDelay
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehicleRespawnDelay
- setVehicleRespawnPosition
- setVehicleSirensOn
- setVehicleTurretPosition
- setVehicleDoorOpenRatio
- setVehicleHandling
- setModelHandling
- setVehicleTurnVelocity
- setVehicleWheelStates
- spawnVehicle
- toggleVehicleRespawn
- getTrainDirection
- getTrainSpeed
- getVehicleHeadLightColor
- getVehicleModelFromName
- getVehicleNameFromModel
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleTaxiLightOn
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainSpeed
- setVehicleHeadLightColor
- setVehicleTaxiLightOn
- getVehicleVariant
- setVehicleVariant
- getVehicleSirenParams
- removeVehicleSirens
- getVehicleSirens
- addVehicleSirens‎
- setVehicleSirens