setTrainDerailed | Multi Theft Auto: Wiki Skip to content

setTrainDerailed

Client-side
Server-side
Shared

Pair: isTrainDerailed

Manual Review Required

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


This function will set a train or tram as derailed.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:setDerailed(...)
  • Variable: .derailed

Syntax

bool setTrainDerailed ( vehicle vehicleToDerail, bool derailed )
Required Arguments
  • vehicleToDerail: The vehicle that you wish to derail.
  • derailed: whether the train is derailed.

Returns

  • bool: value

Returns true if the state was successfully set

Code Examples

shared

This example creates an underailable train, and allows it to be derailed when you want

function makeTrain(thePlayer)
myTrain = createVehicle(537,1995,-1949,13)-- This will make a freight train just east of the LS train station
setTrainDerailable(myTrain, false) -- myTrain can not be derailed now
outputChatBox("A freight train has been created for you.", thePlayer) -- Just a simple message for the player
end
addCommandHandler("trainmeup", makeTrain)
function derailTrain()
setTrainDerailed(myTrain, true) -- When the command is used the train becomes derailed
outputChatBox("Freight train has been derailed!", thePlayer) -- A message to confirm the train was derailed
end
addCommandHandler("derailme", derailTrain)

See Also

Vehicle Functions