---
title: "NPC_GetCurrentPathPointIndex | open.mp"
description: "Gets the current path point index an NPC is moving towards."
canonical: https://omp.itsneufox.com/fa/docs/scripting/functions/NPC_GetCurrentPathPointIndex
language: fa
---

# NPC\_GetCurrentPathPointIndex

هشدار

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

## Description

Gets the current path point index an NPC is moving towards.

| Name | Description |
| --- | --- |
| npcid | The ID of the NPC |

## Returns

Returns the current path point index the NPC is moving towards.

## Examples

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    // The commands to create paths and to create points on paths

    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);

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

forward CheckPathProgress(playerid);
public CheckPathProgress(playerid)
{
    if (!IsPlayerConnected(playerid))
    {
        // Do something about it
        return 0;
    }

    new npcid = PlayerNPC[playerid];
    if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
    {
        // Do something about it
        return 0;
    }

    if (!NPC_IsValidPath(PlayerPatrolPath[playerid]))
    {
        // Do something about it
        return 0;
    }

    new currentPoint = NPC_GetCurrentPathPointIndex(npcid);
    new totalPoints = NPC_GetPathPointCount(PlayerPatrolPath[playerid]);

    if (currentPoint != INVALID_NODE_ID)
    {
        SendClientMessage(playerid, 0xFFFF00FF, "NPC %d progress: Point %d of %d", npcid, currentPoint + 1, totalPoints);
    }
    return 1;
}

```

## Notes

-   Returns -1 if the NPC is not following a path
-   This indicates the point the NPC is currently moving towards

## Related Functions

-   [NPC\_MoveByPath](https://omp.itsneufox.com/fa/docs/scripting/functions/NPC_MoveByPath): Make NPC follow a path
-   [NPC\_CreatePath](https://omp.itsneufox.com/fa/docs/scripting/functions/NPC_CreatePath): Create a new path
-   [NPC\_AddPointToPath](https://omp.itsneufox.com/fa/docs/scripting/functions/NPC_AddPointToPath): Add point to path
-   [NPC\_GetPathPointCount](https://omp.itsneufox.com/fa/docs/scripting/functions/NPC_GetPathPointCount): Get total points in path

## Related Callbacks

-   [OnNPCFinishMovePath](https://omp.itsneufox.com/fa/docs/scripting/callbacks/OnNPCFinishMovePath): Called when NPC finishes path
-   [OnNPCFinishMove](https://omp.itsneufox.com/fa/docs/scripting/callbacks/OnNPCFinishMove): Called when NPC finishes movement
