IsTrainDerailable

From Multi Theft Auto: Wiki
Revision as of 02:33, 15 May 2012 by Kzman (talk | contribs) (Example added)
Jump to navigation Jump to search

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

Syntax

bool isTrainDerailable ( vehicle vehicleToCheck )              

Required Arguments

  • vehicleToCheck: The vehicle you wish to check.

Returns

Returns true if the train is derailable, false otherwise.

Example

This example outputs to the player if the train which he's entered is derrailable or not

Click to collapse [-]
Client
trainModels = { 449, 537, 538, 570, 569, 590 }
lp = getLocalPlayer()
function playerEntered(theVehicle)
	for i,v in ipairs(trainModels) do
		if getElementModel(theVehicle) == v then
			if isTrainDerailable(theVehicle) then
				outputChatBox("Warning: this train could be derailed.")
				return
			else
				outputChatBox("This train is safe.")
			end
		end
	end
end

addEventHandler("onClientPlayerVehicleEnter", getRootElement(), playerEntered)

See Also