09.07.2012, 18:38
The old plugin which was CNPC was deleted due to license violating. You can try the new one HERE
stock Npc: GetClosestNPC(playerid) // This function contributes to the above, as said, to chase a player :D
{
new
Float: fDistance,
Float: fHighest,
Npc: iPlayer = INVALID_CNPC
;
foreachcnpc(npcid)
{
fDistance = GetDistanceBetweenPlayerAndNPC(playerid, npcid);
if(fDistance > fHighest) fHighest = fDistance, iPlayer = Npc: npcid;
}
return iPlayer;
}
new Float: fDistance,
Float: fLowest = 10000.0,
Npc: iPlayer = INVALID_CNPC
;
foreachcnpc(npcid)
{
fDistance = GetDistanceBetweenPlayerAndNPC(playerid, npcid);
if(fDistance < fLowest) fLowest = fDistance, iPlayer = Npc: npcid;
}
return iPlayer;