---
title: "NPC_GetPlayerMovingTo | open.mp"
description: "Obtém o ID do jogador para o qual um NPC está se movendo no momento."
canonical: https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_GetPlayerMovingTo
language: pt-BR
---

# NPC\_GetPlayerMovingTo

aviso

Esta função foi adicionada no omp v1.5.8.3079 e não funcionará em versões anteriores!

## Descrição

Obtém o ID do jogador para o qual um NPC está se movendo no momento.

| Nome | Descrição |
| --- | --- |
| npcid | O ID do NPC |

## Retornos

Retorna o ID do jogador que está sendo movido ou `INVALID_PLAYER_ID` se não estiver se movendo em direção a ninguém.

## Exemplos

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

        if (targetid == INVALID_PLAYER_ID)
            SendClientMessage(playerid, 0x00FF00FF, "NPC %d is not moving toward any player", npcid);
        else
        {
            new targetName[MAX_PLAYER_NAME];
            GetPlayerName(targetid, targetName, sizeof(targetName));
            SendClientMessage(playerid, 0x00FF00FF, "NPC %d is moving toward player %s (ID %d)", npcid, targetName, targetid);
        }
        return 1;
    }
    return 0;
}
```

## Notas

-   Retorna o jogador ID se o NPC estiver se movendo usando [NPC\_MoveToPlayer](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_MoveToPlayer)
-   Retorna `INVALID_PLAYER_ID` se NPC não estiver se movendo em direção a nenhum jogador
-   Isso é diferente de mover para uma posição fixa com [NPC\_Move](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_Move)

## Funções Relacionadas

-   [NPC\_MoveToPlayer](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_MoveToPlayer): Faça NPC se mover em direção a um jogador
-   [NPC\_IsMovingToPlayer](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_IsMovingToPlayer): Verifique se NPC está se movendo em direção a um jogador específico
-   [NPC\_IsMoving](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_IsMoving): Verifique se NPC está se movendo
-   [NPC\_GetPlayerAimingAt](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_GetPlayerAimingAt): Obtenha o jogador que NPC está visando

## Callbacks Relacionadas

-   [OnNPCFinishMove](https://omp.itsneufox.com/pt-BR/docs/scripting/callbacks/OnNPCFinishMove): Chamado quando NPC termina o movimento
