onTrailerAttach
Client-side
Server-side
Shared
This article needs checking:
Cancellation of event has no effect. detachTrailerFromVehicle in the event doesn't work either, 50 ms timer is effective.
This event is triggered when a trailer is attached to a truck or when a tow truck hooks on to a vehicle.
Canceling doesn't appear to work.
Parameters
vehicle theTruck
- theTruck: the truck vehicle that got attached to this trailer.
Source
element: The source of this event is the trailer vehicle that the truck got attached to.
Canceling
If this event is canceled, the trailer will detach from the truck again.
Code Examples
server
This example removes a trailer from the truck it is attached to. Good if you do not want people attaching trailers to vehicles
function detachTrailer(theTruck) --detachTrailerFromVehicle(theTruck, source) --detach the newly attached trailer -- Immediate detatchment of the trailer through cancel event or this method doesn't seem to work so requires a timer: setTimer(detachTrailer2, 50, 1, theTruck, source)endaddEventHandler("onTrailerAttach", getRootElement(), detachTrailer)
function detachTrailer2(theTruck, trailer) if (isElement(theTruck) and isElement(trailer)) then detachTrailerFromVehicle(theTruck, trailer) endend
See Also
Vehicle Events
- onClientTrailerAttach
- onClientTrailerDetach
- onClientVehicleCollision
- onClientVehicleDamage
- onClientVehicleEnter
- onClientVehicleNitroStateChange
- onClientVehicleExit
- onClientVehicleRespawn
- onClientVehicleExplode
- onClientVehicleStartEnter
- onClientVehicleStartExit
- onClientVehicleWeaponHit
- onTrailerDetach
- onTrailerAttach
- onVehicleDamage
- onVehicleEnter
- onVehicleExit
- onVehicleExplode
- onVehicleRespawn
- onVehicleStartEnter
- onVehicleStartExit
Vehicle Functions
- addVehicleSirens
- attachTrailerToVehicle
- addVehicleUpgrade
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getOriginalHandling
- getTrainDirection
- getVehicleCompatibleUpgrades
- getVehicleColor
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehicleNameFromModel
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurnVelocity
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailed
- isVehicleBlown
- isTrainDerailable
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleSirens
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLightState
- setVehicleLandingGearDown
- setVehicleLocked
- setVehicleNitroActivated
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleTurnVelocity
- setVehicleVariant
- setVehicleWheelStates
- spawnVehicleFlyingComponent
- areVehicleLightsOn
- getHelicopterRotorSpeed
- getHeliBladeCollisionsEnabled
- getVehicleAdjustableProperty
- getVehicleComponentPosition
- getVehicleComponentRotation
- getVehicleComponentScale
- getVehicleComponentVisible
- getVehicleCurrentGear
- getVehicleComponents
- getVehicleDummyPosition
- getVehicleEntryPoints
- getVehicleGravity
- getVehicleModelDummyDefaultPosition
- getVehicleModelDummyPosition
- getVehicleModelExhaustFumesPosition
- getVehicleModelWheelSize
- getVehicleNitroCount
- getVehicleNitroLevel
- getVehicleRotorSpeed
- getVehicleRotorState
- getVehicleWheelFrictionState
- getVehicleWheelScale
- isTrainChainEngine
- isVehicleNitroActivated
- isVehicleNitroRecharging
- isVehicleSmokeTrailEnabled
- isVehicleWheelOnGround
- isVehicleWindowOpen
- resetVehicleComponentPosition
- resetVehicleComponentRotation
- resetVehicleComponentScale
- resetVehicleDummyPositions
- setHelicopterRotorSpeed
- setHeliBladeCollisionsEnabled
- setVehicleAdjustableProperty
- setVehicleComponentPosition
- setVehicleComponentRotation
- setVehicleComponentScale
- setVehicleComponentVisible
- setVehicleDummyPosition
- setVehicleGravity
- setVehicleModelDummyPosition
- setVehicleModelExhaustFumesPosition
- setVehicleModelWheelSize
- setVehicleNitroCount
- setVehicleNitroLevel
- setVehicleRotorSpeed
- setVehicleRotorState
- setVehicleSmokeTrailEnabled
- setVehicleWheelScale
- setVehicleWheelsRotation
- setVehicleWindowOpen
- getModelHandling
- getVehicleIdleRespawnDelay
- getVehicleRespawnDelay
- getVehicleRespawnPosition
- getVehicleRespawnRotation
- getVehiclesOfType
- isVehicleRespawnable
- resetVehicleExplosionTime
- resetVehicleIdleTime
- respawnVehicle
- setModelHandling
- setVehicleIdleRespawnDelay
- setVehicleRespawnDelay
- setVehicleRespawnPosition
- setVehicleRespawnRotation
- spawnVehicle
- toggleVehicleRespawn