IsTrainDerailed: Difference between revisions
Jump to navigation
Jump to search
Cazomino05 (talk | contribs) (New page: __NOTOC__ Category:Needs_Example {{Server client function}} This function will check if a train or tram is derailed. ==Syntax== <syntaxhighlight lang="lua"> bool isTrainDerailed ( vehicle vehicleT...) |
mNo edit summary |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | {{Server client function}} | ||
This function will check if a train or tram is derailed. | This function will check if a train or tram is derailed. | ||
Line 8: | Line 7: | ||
bool isTrainDerailed ( vehicle vehicleToCheck ) | bool isTrainDerailed ( vehicle vehicleToCheck ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[vehicle]]:isDerailed|derailed|setTrainDerailed}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''vehicleToCheck:''' | *'''vehicleToCheck:''' the [[vehicle]] that you wish to check is derailed. | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the train is derailed, ''false'' if the train is still on the rails | Returns ''true'' if the train is derailed, ''false'' if the train is still on the rails | ||
==Example== | |||
<section name="Example" class="server" show="true"> | |||
This example lets a player check if the train they're driving has derailed. | |||
<syntaxhighlight lang="lua"> | |||
function checkDerailed(thePlayer) | |||
local theTrain = getPedOccupiedVehicle(thePlayer) | |||
if ( theTrain and getVehicleType(theTrain) == "Train" ) then --is the player in a vehicle and is it a train? | |||
if ( isTrainDerailed(theTrain) ) then --is the train derailed? | |||
outputChatBox("Your train is derailed", thePlayer, 255, 255, 0) --outputs a message | |||
else | |||
outputChatBox("Your train is not derailed", thePlayer, 0, 255, 0) --outputs a message | |||
end | |||
end | |||
end | |||
addCommandHandler("checkTrain", checkDerailed) --adds the command handler | |||
</syntaxhighlight> | |||
</section> | |||
==See Also== | ==See Also== | ||
{{Vehicle_functions}} | {{Vehicle_functions}} |
Latest revision as of 01:45, 7 April 2018
This function will check if a train or tram is derailed.
Syntax
bool isTrainDerailed ( vehicle vehicleToCheck )
OOP Syntax Help! I don't understand this!
- Method: vehicle:isDerailed(...)
- Variable: .derailed
- Counterpart: setTrainDerailed
Required Arguments
- vehicleToCheck: the vehicle that you wish to check is derailed.
Returns
Returns true if the train is derailed, false if the train is still on the rails
Example
Click to collapse [-]
ExampleThis example lets a player check if the train they're driving has derailed.
function checkDerailed(thePlayer) local theTrain = getPedOccupiedVehicle(thePlayer) if ( theTrain and getVehicleType(theTrain) == "Train" ) then --is the player in a vehicle and is it a train? if ( isTrainDerailed(theTrain) ) then --is the train derailed? outputChatBox("Your train is derailed", thePlayer, 255, 255, 0) --outputs a message else outputChatBox("Your train is not derailed", thePlayer, 0, 255, 0) --outputs a message end end end addCommandHandler("checkTrain", checkDerailed) --adds the command handler
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