Pular para o conteúdo principal

NPC_MoveByPath

aviso

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

Descrição

Faz com que um NPC siga um caminho predefinido com várias opções de movimento.

NomeDescrição
npcidO ID do NPC
pathidO ID do caminho a seguir
moveTypeO tipo de movimento (padrão: NPC_MOVE_TYPE_JOG)
moveSpeedVelocidade de movimento (padrão: NPC_MOVE_SPEED_AUTO)
reversedSe deve seguir o caminho inverso (padrão: false)

Retornos

Retorna true se NPC começou a seguir o caminho, false caso contrário.

Exemplos

public OnPlayerCommandText(playerid, cmdtext[])
{
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);

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

Notas

  • O caminho deve ser criado com NPC_CreatePath e conter pelo menos um ponto antes de chamar esta função
  • Use NPC_AddPointToPath para construir a rota e NPC_ClearPath se precisar redefini-la
  • Defina reversed = true para que NPC percorra o caminho na ordem oposta
  • Retorna false se NPC for inválido, já estiver executando uma ação incompatível ou se o caminho não puder ser seguido

Funções Relacionadas

Callbacks Relacionadas