NPC bug?
#1

I had created NPC's by connecting them to server (without recording).
The zombies NPCs are spawned and i set looped timer 250ms where the position of NPC is changed.
But the position is changed after the expiry of one second. Why? Is set changing position after 250ms NOT 1000ms!

You can look at this video:
[ame]http://www.youtube.com/watch?v=xp9uJArU_oc[/ame]

Code:
Код:
public ZombieFunction(playerid)
{
    if(ZombieInfo[playerid][zSpawned])
    {
        if(ZombieInfo[playerid][zAction] == 0)
        {
            new target = GetClosestPlayer(playerid);
            if(target == -1) return 1;
            if(IsHuman(target))
            {
                ZombieInfo[playerid][zTarget] = target;
                ZombieInfo[playerid][zAction] = 1;
            }
        }
        else if(ZombieInfo[playerid][zAction] == 1)
        {
            if(!IsPlayerConnected(ZombieInfo[playerid][zTarget]))
            {
                ZombieInfo[playerid][zAction] = 0;
                ZombieInfo[playerid][zTarget] = -1;
                ZombieInfo[playerid][zRun] = 0;
            }
            new Float:dist = GetDistanceToPlayer(playerid, ZombieInfo[playerid][zTarget]);
            if(dist > 2.0 && dist < 200.0)
            {
                SetPlayerToFacePlayer(playerid, ZombieInfo[playerid][zTarget]);
                ApplyAnimation(playerid, "ped", "sprint_civi", 4.1, 1, 1, 1, 0, 0);
                GetXYInFrontOfPlayer(playerid, ZombieInfo[playerid][zX],ZombieInfo[playerid][zY], 2.0);
                SetPlayerPos(playerid,ZombieInfo[playerid][zX],ZombieInfo[playerid][zY],ZombieInfo[playerid][zZ]);
                new Float:tx, Float:ty, Float:tz;
                GetPlayerPos(ZombieInfo[playerid][zTarget], tx, ty, tz);
                if(z != tz && dist < 30.0)
                {
                    SetPlayerPosFindZ(playerid,ZombieInfo[playerid][zX],ZombieInfo[playerid][zY],ZombieInfo[playerid][zZ]);
                }
            }
        }
    }
    return 1;
}
And setting timer:
Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        ZombieInfo[playerid][zSpawned] = 1;
        SetPlayerPos(playerid, Config[7],Config[8],Config[9]);
        new zskin = random(sizeof(RandZombieSkin));
        SetPlayerHP(playerid, 500.0);
        SetPlayerSkin(playerid, RandZombieSkin[zskin]);
        SetTimerEx("ZombieFunction", 250, 1, "i", playerid);
        return 1;
    }
//More code... []
return 1;
}
This is bug or?
Please help i need to changing position of NPC faster (like run).
Reply
#2

after getting the x- and y position, you need to use
pawn Код:
MoveRNPC(npcid,Float:x,Float:y,Float:z,Float:speed);
...not SetPlayerPos, so your call would be:
pawn Код:
SetPlayerPos(playerid,ZombieInfo[playerid][zX],ZombieInfo[playerid][zY],ZombieInfo[playerid][zZ],0.004);
try larger values than 0.004 for fast sprints. 0.008 or 0.009 is impossible for zombies i bet lol
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)