Pular para o conteúdo principal

NPC_GetCurrentPathPointIndex

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 índice do ponto do caminho atual para o qual um NPC está se movendo.

NomeDescrição
npcidO ID do NPC

Retornos

Retorna o índice do ponto do caminho atual para o qual NPC está se movendo.

Exemplos

public OnPlayerCommandText(playerid, cmdtext[])
{
// Os comandos para criar caminhos e para criar pontos em caminhos

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))
{
// Faça algo sobre isso
return 0;
}

new npcid = PlayerNPC[playerid];
if (npcid == INVALID_NPC_ID || !NPC_IsValid(npcid))
{
// Faça algo sobre isso
return 0;
}

if (!NPC_IsValidPath(PlayerPatrolPath[playerid]))
{
// Faça algo sobre isso
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;
}

Notas

  • Retorna -1 se NPC não estiver seguindo um caminho
  • Isso indica o ponto em que NPC está se movendo atualmente

Funções Relacionadas

Callbacks Relacionadas