跳到主要内容

NPC_GetPathPointCount

注意

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

描述

获取 NPC 路径中点的数量。

参数说明
pathid路径的 ID

返回值

返回路径中点的数量,若路径无效则返回 0。

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkpathpointcount", true))
{
new pathid = PlayerPatrolPath[playerid];
if (pathid == INVALID_PATH_ID)
return SendClientMessage(playerid, 0xFFFF00FF, "未指定巡逻路径。");

new count = NPC_GetPathPointCount(pathid);

SendClientMessage(playerid, 0x00FF00FF, "路径 %d 有 %d 个点", pathid, count);
return 1;
}
return 0;
}

forward ValidatePathBeforeUse(pathid);
public ValidatePathBeforeUse(pathid)
{
new pointCount = NPC_GetPathPointCount(pathid);

if (pointCount < 2)
{
printf("警告: 路径%d只有%d个点,移动需要至少2个点",
pathid, pointCount);
return 0;
}

printf("路径%d有效,有%d个点", pathid, pointCount);
return 1;
}

注意事项

  • 若路径无效或为空则返回 0

相关函数

相关回调