---
title: "NPC_IsMoving | open.mp"
description: "检查 NPC 当前是否正在移动。"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_IsMoving
language: zh-CN
---

# NPC\_IsMoving

注意

这个函数是在omp v1.5.8.3079中添加的，在以前的版本中不起作用！

## 描述

检查 NPC 当前是否正在移动。

| 参数 | 说明 |
| --- | --- |
| npcid | NPC 的 ID |

## 返回值

如果 NPC 正在移动则返回`true`，否则返回`false`。

## 示例

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/checkmoving", true))
    {
        new npcid = PlayerNPC[playerid];
        if (npcid == INVALID_NPC_ID)
            return SendClientMessage(playerid, 0xFF0000FF, "你没有在调试NPC。");

        if (!NPC_IsValid(npcid))
            return SendClientMessage(playerid, 0xFF0000FF, "无效的NPC。");

        new bool:isMoving = NPC_IsMoving(npcid);

        SendClientMessage(playerid, 0x00FF00FF, "NPC %d 正在移动: %s", npcid, isMoving ? "是" : "否");
        return 1;
    }
    return 0;
}
```

## 注意事项

-   当 NPC 正在步行、跑步或驾车前往目的地时返回 true
-   当 NPC 到达目的地或被停止时返回 false

## 相关函数

-   [NPC\_Move](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_Move): 让 NPC 移动到位置
-   [NPC\_StopMove](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_StopMove): 停止 NPC 移动
-   [NPC\_MoveToPlayer](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_MoveToPlayer): 让 NPC 跟随玩家
-   [NPC\_MoveByPath](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_MoveByPath): 让 NPC 跟随路径

## 相关回调

-   [../callbacks/OnNPCFinishMove](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnNPCFinishMove): NPC 完成移动时调用
