SA-MP Forums Archive
NPC + IsPlayerInRangeOfPoint - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: NPC + IsPlayerInRangeOfPoint (/showthread.php?tid=238117)



NPC + IsPlayerInRangeOfPoint - Shoko Lacho - 11.03.2011

Hi guys, i'm using OnPlayerUdpate with IsPlayerInRangeOfPoint to check if a player is close of a certain NPC, but it lag : /

It also make problem with SendClientMessage*

pawn Код:
public OnPlayerUpdate(playerid)
{
    new npcname[MAX_PLAYER_NAME];

    if(IsPlayerNPC(playerid))
    {
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "Target7_Bot", true)) GetPlayerPos(playerid, TargetX, TargetY, TargetZ);
        return 1;
    }
   
    if(TargetChase[playerid]==7)
    {
        if(IsPlayerInRangeOfPoint(playerid, 20.0, TargetX, TargetY, TargetZ))
        {
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                GetPlayerName(i, npcname, sizeof(npcname));
                if(!strcmp(npcname, "Target7_Bot", true))
                {
                    Kick(i);
                    TargetChase[playerid]=0;
                    SendClientMessage(playerid, RED, ">> "WHITE"Mission fail, too close!");
                }
            }
        }
    }
    return 1;
}
*The "Mission fail" message is send like 50 times...


Someone can tell me an alternative ? (Without using OnPlayerUdpate)