跳到主要内容

NPC_GetPlayerMovingTo

注意

This function was added in omp v1.5.8.3079 and will not work in earlier versions!

描述

获取 NPC 当前正移向的玩家 ID。

参数说明
npcidNPC 的 ID

返回值

返回正移向的玩家 ID,若未向任何玩家移动则返回 INVALID_PLAYER_ID

示例

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkwhonpcmoving", 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 targetid = NPC_GetPlayerMovingTo(npcid);

if (targetid == INVALID_PLAYER_ID)
SendClientMessage(playerid, 0x00FF00FF, "NPC %d 没有向任何玩家移动", npcid);
else
{
new targetName[MAX_PLAYER_NAME];
GetPlayerName(targetid, targetName, sizeof(targetName));
SendClientMessage(playerid, 0x00FF00FF, "NPC %d 正在向玩家 %s(ID %d)移动", npcid, targetName, targetid);
}
return 1;
}
return 0;
}

注意事项

  • 若 NPC 使用 NPC_MoveToPlayer 向玩家移动,则返回玩家 ID
  • 若 NPC 未向任何玩家移动,则返回 INVALID_PLAYER_ID
  • 这与使用 NPC_Move 向固定位置移动不同

相关函数

相关回调