IsTrainDerailable

From Multi Theft Auto: Wiki
Revision as of 22:34, 18 December 2014 by Strix (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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