setTrainDerailable | Multi Theft Auto: Wiki Skip to content

setTrainDerailable

Client-side
Server-side
Shared

Pair: isTrainDerailable

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 derailable. This is, if it can derail when it goes above the maximum speed.

OOP Syntax Help! I don't understand this!

  • Method:vehicle:setDerailable(...)
  • Variable: .derailable

Syntax

bool setTrainDerailable ( ​vehicle derailableVehicle, ​bool derailable )
Required arguments
  • derailableVehicle: The vehicle that you wish to set derailable.
  • derailable: whether the train or tram is derailable. True as derailable, False as non-derailable.

Returns

Returns true if the state was successfully set, false otherwise.

  • bool: value

Code Examples

shared

This example will allow players to toggle derailability of the train they are driving

function derailToggle()
local vehicle = getPedOccupiedVehicle(localPlayer)
if not vehicle then return end
if getVehicleType(vehicle) == "Train" and getVehicleController(vehicle) == localPlayer then
setTrainDerailable(vehicle, not isTrainDerailable(vehicle))
outputChatBox("Derailing for this train has been toggled!")
end
end
addCommandHandler("togglederail", derailToggle)

See Also

Vehicle Functions