---
title: "NPC_DestroyPath | open.mp"
description: "Destrói um caminho NPC específico."
canonical: https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_DestroyPath
language: pt-BR
---

# NPC\_DestroyPath

aviso

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

## Descrição

Destrói um caminho NPC específico, tornando-o inválido.

| Nome | Descrição |
| --- | --- |
| pathid | O ID do caminho para destruir |

## Retornos

Retorna `true` em caso de sucesso, `false` em caso de falha.

## Exemplos

```c
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/deletepatrol", true))
    {
        // Verifique se o caminho é válido primeiro
        if (!NPC_IsValidPath(PlayerPatrolPath[playerid]))
        {
            SendClientMessage(playerid, 0xFF0000FF, "No valid patrol path to delete.");
            return 1;
        }

        // Obtenha quantos pontos havia nele
        new count = NPC_GetPathPointCount(PlayerPatrolPath[playerid]);

        // Tente destruí-lo
        if (NPC_DestroyPath(PlayerPatrolPath[playerid]))
        {
            SendClientMessage(playerid, 0x00FF00FF, "Destroyed path %d (%d points removed).", PlayerPatrolPath[playerid], count);

            // Redefinir a variável de caminho do jogador, pois agora ela é inválida
            PlayerPatrolPath[playerid] = INVALID_PATH_ID;
            StopPlayerPatrolTimer(playerid);
        }
        else
        {
            SendClientMessage(playerid, 0xFF0000FF, "Failed to destroy patrol path.");
        }

        return 1;
    }
    return 0;
}
```

## Notas

-   O caminho ID torna-se inválido após destruição
-   NPCs que atualmente segue este caminho irá parar de se mover, pois todos os pontos no caminho foram removidos

## Funções Relacionadas

-   [NPC\_CreatePath](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_CreatePath): Crie um novo caminho
-   [NPC\_IsValidPath](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_IsValidPath): Verifique se um caminho é válido
-   [NPC\_DestroyAllPath](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_DestroyAllPath): Destrua todos os caminhos
-   [NPC\_GetPathCount](https://omp.itsneufox.com/pt-BR/docs/scripting/functions/NPC_GetPathCount): Obtenha o número total de caminhos

## Callbacks Relacionadas

-   [OnNPCFinishMovePath](https://omp.itsneufox.com/pt-BR/docs/scripting/callbacks/OnNPCFinishMovePath): Chamado quando NPC termina um caminho
