[NPC]Function don't work
#1

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 )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)