28.09.2011, 14:38
You should be using foreach and not OnPlayerUpdate.
Include YSI\y_timers and foreach and make a new timer
After you do that, create a new function called OnPlayerNearNPC.
Enjoy. This is faster than the one above me.
Include YSI\y_timers and foreach and make a new timer
pawn Код:
Timer:UpdatePlayer[250]() {
foreach(Player, playerid) {
if(!IsPlayerNPC(playerid)) {
foreach(Player, npcid) {
if(IsPlayerNPC(npcid)) {
new Float:rPos[3];
GetPlayerPos(npcid, rPos[0], rPos[1], rPos[2]);
if(IsPlayerInRangeOfPoint(playerid, 8.0, rPos[0], rPos[1], rPos[2])) {
OnPlayerNearNPC(playerid, npcid);
}
}
}
}
}
}
pawn Код:
OnPlayerNearNPC(playerid, npcid)
{
// Code inside here
}