跳到主要内容

NPC_RemovePointFromPath

注意

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

描述

从 NPC 路径中移除路径点。

参数说明
pathid路径的 ID
point_index要移除的点的索引

返回值

成功时返回true,失败时返回false

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strncmp(cmdtext, "/removepatrolpoint ", 19, true))
{
if (!NPC_IsValidPath(PlayerPatrolPath[playerid]))
{
SendClientMessage(playerid, 0xFF0000FF, "没有有效的巡逻路径。先使用/createpatrol。");
return 1;
}

new pointIndex = strval(cmdtext[19]);
new totalPoints = NPC_GetPathPointCount(PlayerPatrolPath[playerid]);

if (pointIndex < 0 || pointIndex >= totalPoints)
{
SendClientMessage(playerid, 0xFF0000FF, "无效的点索引。有效范围:0-%d", totalPoints - 1);
return 1;
}

if (NPC_RemovePointFromPath(PlayerPatrolPath[playerid], pointIndex))
{
SendClientMessage(playerid, 0x00FF00FF, "从路径 %d 中移除点 %d(现在有 %d 个点)", pointIndex, PlayerPatrolPath[playerid], totalPoints - 1);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "未能从路径中移除点%d", pointIndex);
}
return 1;
}
return 0;
}

注意事项

  • 点索引从 0 开始
  • 移除点会将所有后续点的索引向下移动一位
  • 如果指定的索引超出范围,函数将返回false
  • 不能从无效路径中移除点

相关函数

相关回调