Chuyển tới nội dung chính

NPC_PlayNode

cảnh báo

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

Description

Makes an NPC navigate through predefined navigation nodes using the game's built-in navigation system.

NameDescription
npcidThe ID of the NPC
nodeIdThe ID of the node to navigate
moveTypeMovement type (default: NPC_MOVE_TYPE_JOG)
Float:speedMovement speed (default: NPC_MOVE_SPEED_AUTO)
Float:radiusRadius around nodes to consider as reached (default: 0.0)
bool:setangleWhether to update NPC's facing angle during navigation (default: true)

Returns

Returns true if the NPC started playing the node, false otherwise.

Examples

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

if (!NPC_IsValid(npcid))
return SendClientMessage(playerid, 0xFF0000FF, "Invalid NPC.");

new nodeid = strval(cmdtext[13]);

if (nodeid < 0 || nodeid > 63)
return SendClientMessage(playerid, 0xFF0000FF, "Invalid node ID. Must be between 0 and 63.");

new bool:success = NPC_PlayNode(npcid, nodeid, NPC_MOVE_TYPE_JOG, NPC_MOVE_SPEED_AUTO, 0.0, true);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d play node %d: %s", npcid, nodeid, success ? "Success" : "Failed");
return 1;
}
return 0;
}

Notes

  • Nodes are predefined navigation points from the game's node files (IDs 0-63)
  • The node must be opened with NPC_OpenNode before it can be used
  • The NPC will automatically navigate between points within the specified node
  • Use setAngle parameter to control whether the NPC rotates to face movement direction
  • The radius parameter determines how close the NPC needs to get to each point
  • Node navigation can be paused, resumed, or stopped using related functions