getTrainDirection | Multi Theft Auto: Wiki Skip to content

getTrainDirection

Client-side
Server-side
Shared

Pair: setTrainDirection

This page is incomplete! Help wanted!

Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.


Gets the direction in which a train is driving (clockwise or counterclockwise).

Syntax

getTrainDirection ( )

Code Examples

server

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

Vehicle Functions