---
title: "AddStaticVehicleEx | open.mp"
description: "在游戏模式中添加可自定义重生时间的静态车辆（模型会预加载给玩家）"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/AddStaticVehicleEx
language: zh-CN
---

# AddStaticVehicleEx

## 描述

在游戏模式中添加静态车辆（模型会预加载给玩家）。

与 AddStaticVehicle 的唯一区别：可设置车辆无人驾驶后的重生时间。

| 参数 | 说明 |
| --- | --- |
| modelid | [车辆模型 ID](https://omp.itsneufox.com/zh-CN/docs/scripting/resources/vehicleid) |
| Float:spawnX | 生成点的 X 坐标 |
| Float:spawnY | 生成点的 Y 坐标 |
| Float:spawnZ | 生成点的 Z 坐标 |
| Float:angle | 车辆初始朝向角度 |
| [colour1](https://omp.itsneufox.com/zh-CN/docs/scripting/resources/vehiclecolorid) | 主颜色 ID |
| [colour2](https://omp.itsneufox.com/zh-CN/docs/scripting/resources/vehiclecolorid) | 副颜色 ID |
| respawnDelay | 车辆无人驾驶后的重生延迟（单位：秒） |
| bool:addSiren | 默认值'false'。为车辆添加警报器功能（需车辆自带喇叭） |

## 返回值

成功创建的车辆 ID（范围 1 至 MAX\_VEHICLES）。

若创建失败（达到车辆上限或无效模型 ID）返回 INVALID\_VEHICLE\_ID（65535）。

## 示例

```c
public OnGameModeInit()
{
    // 添加一架九头蛇战斗机（520），无人驾驶15秒后重生
    AddStaticVehicleEx(520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 15);

    return 1;
}
```

## 相关函数

-   [AddStaticVehicle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/AddStaticVehicle): 添加基础静态车辆
-   [CreateVehicle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/CreateVehicle): 动态创建车辆
-   [DestroyVehicle](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/DestroyVehicle): 销毁车辆
-   [GetVehicleParamsSirenState](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleParamsSirenState): 检测车辆警报器状态
-   [SetVehicleSpawnInfo](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetVehicleSpawnInfo): 配置车辆生成参数
-   [GetVehicleSpawnInfo](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleSpawnInfo): 获取车辆生成信息
-   [ChangeVehicleColours](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/ChangeVehicleColours): 修改车辆颜色
-   [GetVehicleColours](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleColours): 获取车辆颜色配置
-   [SetVehicleRespawnDelay](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/SetVehicleRespawnDelay): 设置车辆重生延迟
-   [GetVehicleRespawnDelay](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/GetVehicleRespawnDelay): 获取车辆重生延迟

## 相关回调

-   [OnVehicleSpawn](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnVehicleSpawn): 车辆重生时触发
-   [OnVehicleSirenStateChange](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnVehicleSirenStateChange): 车辆警报器状态变化时触发

## 相关资源

-   [车辆模型列表](https://omp.itsneufox.com/zh-CN/docs/scripting/resources/vehicleid): 游戏内所有车辆模型的完整清单
-   [车辆颜色 ID](https://omp.itsneufox.com/zh-CN/docs/scripting/resources/vehiclecolorid): 所有车辆颜色 ID 对照表
