---
title: "NPC_GetNodeType | open.mp"
description: "获取 NPC 节点的类型。"
canonical: https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_GetNodeType
language: zh-CN
---

# NPC\_GetNodeType

注意

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

## 描述

获取 NPC 节点的类型。

| 参数 | 说明 |
| --- | --- |
| nodeid | 节点的 ID |

## 返回值

返回节点类型 ID，若节点无效则返回-1。

## 示例

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/checknodetype ", true, 15))
    {
        new nodeid = strval(cmdtext[15]);

        if (nodeid < 0 || nodeid > 63)
            return SendClientMessage(playerid, 0xFF0000FF, "无效的节点 ID。必须在 0 到 63 之间。");

        new nodetype = NPC_GetNodeType(nodeid);

        SendClientMessage(playerid, 0x00FF00FF, "节点 %d 类型：%d", nodeid, nodetype);
        return 1;
    }
    return 0;
}
```

## 注意事项

-   若节点无效或未打开则返回-1
-   不同的节点类型适用于不同的移动方式
-   行人节点适用于步行的 NPC
-   车辆节点适用于驾驶的 NPC
-   请为 NPC 的移动方式选择合适的节点类型

## 相关函数

-   [NPC\_OpenNode](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_OpenNode): 打开节点以供使用
-   [NPC\_IsNodeOpen](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_IsNodeOpen): 检查节点是否打开
-   [NPC\_GetNodeInfo](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_GetNodeInfo): 获取详细节点信息
-   [NPC\_PlayNode](https://omp.itsneufox.com/zh-CN/docs/scripting/functions/NPC_PlayNode): 使 NPC 播放节点

## 相关回调

-   [../callbacks/OnNPCFinishNode](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnNPCFinishNode): NPC 完成节点时调用
-   [../callbacks/OnNPCChangeNode](https://omp.itsneufox.com/zh-CN/docs/scripting/callbacks/OnNPCChangeNode): NPC 更换节点时调用
