IsTrainDerailable

From Multi Theft Auto: Wiki
Jump to: navigation, search

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

Syntax

bool isTrainDerailable ( vehicle vehicleToCheck )              

OOP Syntax Help! I don't understand this!

Method: vehicle:isDerailable(...)
Variable: .derailable
Counterpart: setTrainDerailable

Required Arguments

  • vehicleToCheck: The vehicle you wish to check.

Returns

Returns true if the train is derailable, false otherwise.

Example

This example warns the player if their train can be derailed.

Click to collapse [-]
Client
local function playerVehicleEnter()
	local localVehicle = getPedOccupiedVehicle(localPlayer)
	if not isElement(localVehicle) then return end -- In case getPedOccupiedVehicle() does not return a valid vehicle, for whatever reason
	
	if getVehicleType(localVehicle) == "Train" then
		if isTrainDerailable(localVehicle) then
			outputChatBox("* Warning: this train could derail!", 255, 0, 0)
		end
	end
end
addEventHandler("onClientPlayerVehicleEnter", localPlayer, playerVehicleEnter)

See Also

FROM VERSION 1.6 r7485 ONWARDS
FROM VERSION 1.6 r7485 ONWARDS