getTrainPosition | Multi Theft Auto: Wiki Skip to content

getTrainPosition

Client-side
Server-side
Shared

Pair: setTrainPosition

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 position the train is currently on the track

Syntax

getTrainPosition ( )

Code Examples

server

This example adds a command called "/getpos", allowing you to get the position of the train.

function position(player)
if player and isElement(player) then
if isPedInVehicle(player) then -- make sure we're actually in a vehicle
local vehicle = getPedOccupiedVehicle(player)
if vehicle then
local vehType = getVehicleType (vehicle)
if vehType == "Train" then -- make sure we're in a train
local position = getTrainPosition (vehicle)
outputChatBox("The Train position is: "..position)
else
outputChatBox("You are not in a train!")
end
end
else
outputChatBox("You are not in a vehicle!")
end
end
end
addCommandHandler("getpos",position)

See Also

Vehicle Functions