DetachTrailerFromVehicle: Difference between revisions
Jump to navigation
Jump to search
m (→Example) |
|||
| Line 21: | Line 21: | ||
detachTrailerFromVehicle ( source ) --detach the truck from the trailer | detachTrailerFromVehicle ( source ) --detach the truck from the trailer | ||
removeEventHandler ( "onVehicleDamage", source, onTrailerDamage ) | removeEventHandler ( "onVehicleDamage", source, onTrailerDamage ) | ||
-- remove the event handler so that this function is no longer called when the trailer is damaged | |||
end | end | ||
end | end | ||
Revision as of 23:55, 28 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 attaches a trailer to a truck, and detaches it if the trailer is damaged:
function onTrailerDamage ( loss )
if ( loss > 50 ) then --if the health loss was more than 50
detachTrailerFromVehicle ( source ) --detach the truck from the trailer
removeEventHandler ( "onVehicleDamage", source, onTrailerDamage )
-- remove the event handler so that this function is no longer called when the trailer is damaged
end
end
function createVehiclesAndAttachThem ()
local theTruck = createVehicle ( 515, 500, 500, 40 ) -- create a trailer-tower (roadtrain)
local theTrailer = createVehicle ( 435, 500, 505, 40 ) -- create a trailer
attachTrailerToVehicle ( theTruck, theTrailer ) -- attach them
-- add an event handler for when the trailer is damaged
addEventHandler ( "onVehicleDamage", theTrailer, onTrailerDamage )
end
See Also
- addVehicleUpgrade
- addVehicleSirens
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- setVehicleNitroActivated
- 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
- removeVehicleSirens
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates