முதன்மை உள்ளடக்கத்துக்குச் செல்லவும்

NPC_MoveByPath

எச்சரிக்கை

செயல்பாடு என்பது omp v1.5.8.3079 பதிப்பில் சேர்க்கப்பட்டது. இது முந்தைய பதிப்புகளில் இயங்காது!

Description​

Makes an NPC follow a predefined path with various movement options.

NameDescription
npcidThe ID of the NPC
pathidThe ID of the path to follow
moveTypeThe movement type (default: NPC_MOVE_TYPE_JOG)
moveSpeedMovement speed (default: NPC_MOVE_SPEED_AUTO)
reversedWhether to follow path in reverse (default: false)

Returns​

Returns true if the NPC started following the path, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/startpatrol", true))
{
new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID)
return SendClientMessage(playerid, 0xFF0000FF, "You are not debugging a NPC.");

new count = NPC_GetPathPointCount(PlayerPatrolPath[playerid]);

if (NPC_IsValidPath(PlayerPatrolPath[playerid]))
{
NPC_MoveByPath(npcid, PlayerPatrolPath[playerid], NPC_MOVE_TYPE_WALK);
SendClientMessage(playerid, 0x00FF00FF, "NPC %d started patrol route with %d points", npcid, count);

StopPlayerPatrolTimer(playerid);
PlayerPatrolTimer[playerid] = SetTimerEx("CheckPathProgress", 2000, true, "i", playerid);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Failed to start patrol route");
}
return 1;
}
return 0;
}

Notes​

  • Path must be created with NPC_CreatePath and contain at least one point before calling this function
  • Use NPC_AddPointToPath to build the route and NPC_ClearPath if you need to reset it
  • Set reversed = true to have the NPC traverse the path in the opposite order
  • Returns false if the NPC is invalid, already performing an incompatible action, or the path cannot be followed