إنتقل إلى المحتوى الرئيسي

NPC_HasPathPointInRange

warning

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

Description​

Checks if a path has any point within the specified range from given coordinates.

NameDescription
pathIdThe ID of the path to check
xThe X coordinate of the center position
yThe Y coordinate of the center position
zThe Z coordinate of the center position
radiusThe radius to check for path points within

Returns​

Returns true if the path has at least one point within the specified range, false otherwise.

Examples​

public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkpathpointinrange ", true, 23))
{
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 pathid = strval(cmdtext[23]);

new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
new bool:hasPoint = NPC_HasPathPointInRange(pathid, x, y, z, 50.0);

SendClientMessage(playerid, 0x00FF00FF, "Path %d has point near your position (%.2f, %.2f, %.2f): %s", pathid, x, y, z, hasPoint ? "Yes" : "No");
return 1;
}
return 0;
}

Notes​

  • This function is useful for checking if an NPC path intersects with a specific area or location before starting path movement
  • The function checks the 3D distance between the given position and each path point
  • Only valid paths with at least one point can return true

No specific callbacks are triggered by this function.