IsTrainDerailable: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 7: | Line 7: | ||
bool isTrainDerailable ( vehicle vehicleToCheck ) | bool isTrainDerailable ( vehicle vehicleToCheck ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:isDerailable|derailable|setTrainDerailable}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''vehicleToCheck:''' The vehicle you wish to check. | *'''vehicleToCheck:''' The vehicle you wish to check. | ||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
<section name=" | This example warns the player if their train can be derailed. | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | 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) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> | ||
Line 23: | Line 34: | ||
==See Also== | ==See Also== | ||
{{Vehicle_functions}} | {{Vehicle_functions}} | ||
Latest revision as of 22:34, 18 December 2014
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 [-]
Clientlocal 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
- 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