---
title: "IsTrailerAttachedToVehicle | open.mp"
description: "检测车辆是否连接有拖车。"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/IsTrailerAttachedToVehicle
language: zh-CN
---

# IsTrailerAttachedToVehicle

## 描述

检测指定车辆是否连接有拖车。可通过[GetVehicleTrailer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleTrailer)获取拖车 ID（若存在）。

| 参数 | 说明 |
| --- | --- |
| vehicleid | 要检测的车辆 ID |

## 返回值

**true** - 车辆当前连接拖车

**false** - 车辆未连接拖车

## 示例代码

```c
if (IsTrailerAttachedToVehicle(vehicleid))
{
    printf("车辆 %i 正在牵引拖车！", vehicleid);
}
```

## 相关函数

-   [GetVehicleTrailer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleTrailer): 获取车辆牵引的拖车 ID
-   [AttachTrailerToVehicle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/AttachTrailerToVehicle): 将拖车连接到车辆
-   [DetachTrailerFromVehicle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/DetachTrailerFromVehicle): 解除车辆与拖车的连接
