SA-MP Forums Archive
[NPC]Function don't work - 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]Function don't work (/showthread.php?tid=185560)



[NPC]Function don't work - MyLife - 25.10.2010

This is my problem function.

pawn Код:
public OnNPCSpawn(npcid)
{
    SetTimerEx("ZombieCheck",3000,1,"d",npcid);
   
}
forward ZombieCheck(playerid);
public ZombieCheck(playerid)
{
        new t = GetClosestPlayer(playerid);
        new Float:tx,Float:ty,Float:tz;
        if(GetDistanceBetweenPlayers(playerid,t) < 10) //<< this fucntion don't work
        {
            if(IsPlayerNPC(t)) return 1;
            Zombie[playerid][target] = t; //<< target = Closest player
            Zombie[playerid][chasing] = t;
            Zombie[playerid][idle] = 0;
            GetPlayerPos(t,tx,ty,tz);
            NPC_RunTo(playerid,tx,ty,tz,1); //<< Set npc run to target
            ApplyAnimation (playerid, "playerid", "run_old", 4.1, 1, 1, 1 ,1,1,1);
              printf("Zombie found target %d",t);
            return 1;
        }
        else if(GetDistanceBetweenPlayers(Zombie[playerid][target],playerid) > 11)
        {
            Zombie[playerid][idle] = 1;
            Zombie[playerid][target] = 999;
            Zombie[playerid][chasing] = 999;
            print("Zombie giveup");
            return 1;
        }
        return 1;
}
My problem is when zombie near target < 10 it not do anything.

( I use with INC CNPC )