setTrainDirection | Multi Theft Auto: Wiki Skip to content

setTrainDirection

Client-side
Server-side
Shared

Pair: getTrainDirection

Manual Review Required

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


Sets the direction in which a train or tram drives over the rails (clockwise or counterclockwise).

OOP Syntax Help! I don't understand this!

  • Method:vehicle:setDirection(...)
  • Variable: .direction

Syntax

bool setTrainDirection ( vehicle train, bool clockwise )
Required Arguments
  • train: the train whose direction to change.
  • clockwise: if true , will make the train go clockwise. If false , makes it go counterclockwise.

Returns

  • bool: value

Returns true if successful, false otherwise.

Code Examples

shared

This function will make a train driving clockwise.

function createTrain(source)
local myTrain = createVehicle(537,1995,-1949,13) -- Create the train
setTrainDirection(myTrain, true) -- Make the train drive clockwise
setTrainSpeed(myTrain, 1) -- Speed up
end
addCommandHandler("mytrain", createTrain)

See Also

Vehicle Functions