Passa al contenuto principale

NPC_IsAimingAtPlayer

warning

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

Description

Checks if an NPC is aiming at a specific player.

NameDescription
npcidThe ID of the NPC
playeridThe ID of the player to check

Returns

Returns true if the NPC is aiming at the specified player, false otherwise.

Examples


public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/checkaimingat", 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 bool:isAimingAtPlayer = NPC_IsAimingAtPlayer(npcid, playerid);

SendClientMessage(playerid, 0x00FF00FF, "NPC %d is aiming at you: %s", npcid, isAimingAtPlayer ? "Yes" : "No");
return 1;
}
return 0;
}

Notes

  • Returns true only when the NPC is specifically targeting the given player
  • Use this to check if a player is being targeted by an NPC
  • The NPC must be using NPC_AimAtPlayer for this to return true