[Tutorial] [TUT]How to force a NPC to do an Animation
#1

I have made this Tutorial to help in the future people that might have the same problem that i had, here's how you do it.
First add a animation command in your game mode.
Like this:
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmd, "/Owned", true) == 0)
  {
     ApplyAnimation(playerid,"ped","KO_shot_front",1,0,1,0,1,0);
     return 1;
  }
}
Now make sure you have your npc connected to your server and then you can add this line to your NPC file that is in the npcmodes folder.
Code:
#define RECORDING "YourNPCname" 
#define RECORDING_TYPE 2

#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);

public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
--------------------------------------
public OnPlayerStreamIn(playerid)  
{                        
	SendCommand("/Owned");        <---------------- YOU'LL HAVE TO ADD THIS PUBLIC WITH THE REST
                                           UNDER THE OnNPCSpawn()
	return 1;               
}                        
--------------------------------------
And that's all!
Easy enough

Thank Boelie, not me for teaching me this so i could share with others.
Reply
#2

Very nice dude

and btw you dont even need the npc to make a recording. setplayerpos on onplayerspawn will do fine to.
Reply
#3

Looks gr8 will defenlty help alot of scripters.
Reply
#4

Thank you
Reply
#5

Theres a better way of doing this but yeah good
Reply
#6

Quote:
Originally Posted by Joe Torran C
Theres a better way of doing this but yeah good
Ye i know but this 1 is simple :P
Reply
#7

Quote:
Originally Posted by Joe Torran C
Theres a better way of doing this but yeah good
Whats the better way
Cause this didnt work for me
Reply
#8

Quote:

Whats the better way
Cause this didnt work for me

Hi i saw your topic and i know why its not working..
take a close look at your ApplyAnimation if the numbers are set like this:

2.1,1,0,0,0,0

the npc will repeat its animation

if its set to this; 2.1,1,0,0,1,0

THe npc wont repeat but stays at the animation ending ( so for you that will be sitting down)
just change the 0 into 1.

cheers!
Reply
#9

If you do an animation while using npcrecord that animation will playback when the bot connects.

Reply
#10

Quote:
Originally Posted by CJ101
If you do an animation while using npcrecord that animation will playback when the bot connects.

I have already Tried that and all the NPC does is moves back and forth from left to right.
Reply
#11

don't work in my NPCs
Please help
Reply
#12

Quote:
Originally Posted by Vladeksh
don't work in my NPCs
Please help
Tell us what you have done so far or what exactly isnt working..or post the stuff you made so we can help
Reply
#13

Quote:
Originally Posted by boelie
Quote:
Originally Posted by Vladeksh
don't work in my NPCs
Please help
Tell us what you have done so far or what exactly isnt working..or post the stuff you made so we can help
Ok

My NPC Terror_1.pwn:
pawn Code:
#define RECORDING "TerrorMo_1"
#define RECORDING_TYPE 2

#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);

public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
 
public OnPlayerStreamIn(playerid)
{
    SendCommand("/handsup");
    return 1;
}
public OnGameModeInit()
pawn Code:
ConnectNPC("NPC_Terrorist1","Terror_1");
public OnPlayerSpawn(playerid)
pawn Code:
if(!strcmp(npcname, "NPC_Terrorist1", true))
    {
      SetPlayerSkin(playerid,164);
    }
    return 1;
And the command:
pawn Code:
if(strcmp(cmd, "/handsup", true) == 0 || strcmp(cmd, "/rendirse", true) == 0)
{
    ApplyAnimation(playerid,"ROB_BANK","SHP_HandsUp_Scr",4.1,0,0,0,1,0);
    return 1;
}
Reply
#14

Help please
Reply
#15

I tested the animation just to type the command.
Only at the third time it worked

anyway i dont think the npc can use a command like you made here;

if(strcmp(cmd, "/handsup", true) == 0 || strcmp(cmd, "/rendirse", true) == 0)


test it without the /rendirse part . so just with /handsup and check if it works
Reply
#16

if(strcmp(cmd, "/handsup", true) == 0)

not work
I recorded the NPC without animation, after I record it doing the animation
maybe a problem with that?
Reply
#17

Quote:
Originally Posted by CJ101
If you do an animation while using npcrecord that animation will playback when the bot connects.

Used to in the 0.3RC versions but doesn't any more. You need to preload animations now.

Quote:
Originally Posted by boelie
I tested the animation just to type the command.
Only at the third time it worked
As I said before you need to preload animations for them to work properly.

Reply
#18

Quote:

As I said before you need to preload animations for them to work properly.

how?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)