DetachTrailerFromVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This example will create a trailer and a trailer-tower, attach them, then detach them. | '''Example 1:''' This example will create a trailer and a trailer-tower, attach them, then detach them. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
theVehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain) | |||
trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer | trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer | ||
detachTrailerFromVehicle ( theVehicle ) -- detach any old trailers from this vehicle | |||
detachTrailerFromVehicle ( | attachTrailerToVehicle ( theVehicle, trailer ) -- attach them | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Example 2:''' <syntaxhighlight lang="lua">This example will detach any trailers from a vehicle if it was damaged significantly. | |||
function removeTrailerOnDamage ( loss ) | |||
if loss > 20 then --if the loss was more than 20 | |||
detachTrailerFromVehicle ( source ) --detach any vehicles | |||
end | |||
end | |||
addEventHandler ( "onVehicleDamage", getRootElement(), removeTrailerOnDamage ) --add the event handler for onVehicleDamage</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 23:08, 15 July 2007
This function detaches an already attached trailer from a vehicle.
Syntax
bool detachTrailerFromVehicle ( vehicle theVehicle, [vehicle theTrailer] )
Required Arguments
- theVehicle: The vehicle you wish to detach a trailer from.
Optional Arguments
- theTrailer: The trailer you wish to be detached.
Note: If 'theTrailer' is specified, it will only detach if this matches. If it is not specified, any trailer attached to 'theVehicle' will be detached.
Returns
Returns 'true' if the vehicle's were successfully detached, 'false' otherwise.
Example
Example 1: This example will create a trailer and a trailer-tower, attach them, then detach them.
theVehicle = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain) trailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer detachTrailerFromVehicle ( theVehicle ) -- detach any old trailers from this vehicle attachTrailerToVehicle ( theVehicle, trailer ) -- attach them
Example 2:
This example will detach any trailers from a vehicle if it was damaged significantly. function removeTrailerOnDamage ( loss ) if loss > 20 then --if the loss was more than 20 detachTrailerFromVehicle ( source ) --detach any vehicles end end addEventHandler ( "onVehicleDamage", getRootElement(), removeTrailerOnDamage ) --add the event handler for onVehicleDamage
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