IsTrainDerailable: Difference between revisions
Jump to navigation
Jump to search
(Example added) |
|||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
<section name=" | This example outputs to the player if the train which he's entered is derrailable or not | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
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) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 23: | Line 39: | ||
==See Also== | ==See Also== | ||
{{Vehicle_functions}} | {{Vehicle_functions}} | ||
Revision as of 02:33, 15 May 2012
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 [-]
ClienttrainModels = { 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
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates