Running NPC
#1

I tried to make an NPC apply the running animation. It is running but it stays in the same place, I can see it running but it's like it's frozen.
pawn Code:
public SyncNPC()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
    for(new npc=0; npc<MAX_PLAYERS; npc++)
    {
        if(IsPlayerNPC(npc))
        {
                new Float:Xnpc, Float:Ynpc, Float:Znpc;
                GetPlayerPos(npc, Xnpc, Ynpc, Znpc);
                if(IsPlayerInRangeOfPoint(i, 150.0, Xnpc, Ynpc, Znpc))
                {
                    new npcname[MAX_PLAYER_NAME];
                    GetPlayerName(npc, npcname, sizeof(npcname));
                    if(!strcmp(npcname, "Jimmeh", true))
                    {
                        new stringnpc[256];
                        format(stringnpc, sizeof(stringnpc), "{ee5555}Jimmeh says: {FFFFFF}Test!");
                        ProxDetector(30.0, i, stringnpc, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        new Float:Xplaya, Float:Yplaya, Float:Zplaya;
                        GetPlayerPos(i, Xplaya, Yplaya, Zplaya);
                        ApplyAnimation(npc,"ped","null",0.0,0,0,0,0,0);
                        SetPlayerLookAt(npc,Xplaya, Yplaya);
                        ApplyAnimation(npc,"ped","run_player", 4.1, 1, 1, 1, 1, 0);
                        TogglePlayerControllable(npc, 1);
                        //ApplyAnimation(playerid,"ped","WALK_player", 4.1, 1, 1, 1, 0, 0);
                    }
                }
        }
    }
    }
    }
}
Reply
#2

NPCs now hold thier animations when recorded or so I've heard some time ago, but never did test it out...

But I know there is a Run Animation that would cause a player to run without using the Run Button
So maybe try other Run Animations with your NPC first?
Reply
#3

Well, there are lots of animations.. I tested the walk animation too, though - it did the same.
Reply
#4

Don't know what else to really tell you, recording the NPC running doesn't work or just something you're not really wanting? I don't know what animation it was though, but maybe test on a player, then your NPC?

If it stops your NPC dead in its tracks though, I don't think you can do anything more about it though
(Nothing that I can think of anyways)
Reply
#5

Well, I recorded the NPC standing in one place, not moving. The playback doesn't replay because I uncommented the line. I want the NPC to move when a player is in range of it.
Reply
#6

Oh... Well that changes everything then... Hmm

I know there are ways to do this, but this is not my speciality

Perphaps record it to run where-ever, then give it the stand animation or something to keep it still (Hopefully)
Then when a player is close enough, remove the animation and replay the NPC

Hopefully someone else knows about creating NPC AI or whatever. Also, might want to search forum for any similar releases and review the code which might give you some insight on how to do this
Reply
#7

You want to play a running recording when any player is close?
Reply
#8

No, I want the NPC to apply the animation(run to the player) when the player is close.
Reply
#9

I think it's not possible. You can apply the animation, but NPC doesn't move.
Reply
#10

I think it might be possible sir...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)