# onTrailerAttach (Servidor)

> Se dispara en el servidor cuando un remolque se engancha a un vehículo. Cancelar el evento suelta el remolque.

- **Plataforma**: MY Multiplayer (MYMP)
- **Tipo**: Evento Lua
- **Lado**: Servidor
- **Categoría**: Vehículos
- **Cancelable**: `cancelEvent`
- **URL**: https://wiki.mymp.gg/es/onTrailerAttach

## Sintaxis

```lua
addEventHandler("onTrailerAttach", root, function(vehicle towedBy) ... end)
```

## Parámetros del handler

| Nombre | Tipo | Descripción |
| --- | --- | --- |
| `towedBy` | `vehicle` | El vehículo que pasó a arrastrar el remolque. |

## Source

El remolque.

## Ejemplo

```lua
addEventHandler("onTrailerAttach", root, function(towedBy)
    if isVehicleLocked(source) then
        cancelEvent()
    end
end)
```

## Ver también

- [onTrailerDetach (Servidor)](https://wiki.mymp.gg/es/onTrailerDetach.md): Se dispara en el servidor cuando un remolque se suelta del vehículo que lo arrastraba.
- [onClientTrailerAttach (Cliente)](https://wiki.mymp.gg/es/onClientTrailerAttach.md): Se dispara en el cliente cuando un remolque se engancha a un vehículo.
- [getVehicleTowedByVehicle (Compartido)](https://wiki.mymp.gg/es/getVehicleTowedByVehicle.md): Devuelve el remolque o vehículo que este vehículo está remolcando.
- [getVehicleTowingVehicle (Compartido)](https://wiki.mymp.gg/es/getVehicleTowingVehicle.md): Devuelve el vehículo que está remolcando a este vehículo.
