isTrainDerailed | Multi Theft Auto: Wiki Skip to content

isTrainDerailed

Client-side
Server-side
Shared

Pair: setTrainDerailed

This page is incomplete! Help wanted!

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


This function will check if a train or tram is derailed.

Syntax

isTrainDerailed ( )

Code Examples

server

This example lets a player check if the train they're driving has derailed.

function checkDerailed(thePlayer)
local theTrain = getPedOccupiedVehicle(thePlayer)
if ( theTrain and getVehicleType(theTrain) == "Train" ) then --is the player in a vehicle and is it a train?
if ( isTrainDerailed(theTrain) ) then --is the train derailed?
outputChatBox("Your train is derailed", thePlayer, 255, 255, 0) --outputs a message
else
outputChatBox("Your train is not derailed", thePlayer, 0, 255, 0) --outputs a message
end
end
end
addCommandHandler("checkTrain", checkDerailed) --adds the command handler

See Also

Vehicle Functions