SA-MP Forums Archive
[Tutorial] [TUT]How to force a NPC to do an Animation - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [TUT]How to force a NPC to do an Animation (/showthread.php?tid=135986)



[TUT]How to force a NPC to do an Animation - Epic Shower - 22.03.2010

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.


Re: [TUT]How to force a NPC to do an Animation - boelie - 23.03.2010

Very nice dude

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


Re: [TUT]How to force a NPC to do an Animation - 02manchestera - 23.03.2010

Looks gr8 will defenlty help alot of scripters.


Re: [TUT]How to force a NPC to do an Animation - Epic Shower - 24.03.2010

Thank you


Re: [TUT]How to force a NPC to do an Animation - Torran - 24.03.2010

Theres a better way of doing this but yeah good


Re: [TUT]How to force a NPC to do an Animation - Epic Shower - 29.03.2010

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


Re: [TUT]How to force a NPC to do an Animation - deather - 29.03.2010

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


Re: [TUT]How to force a NPC to do an Animation - boelie - 29.03.2010

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!


Re: [TUT]How to force a NPC to do an Animation - CJ101 - 29.03.2010

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




Re: [TUT]How to force a NPC to do an Animation - WSD - 15.06.2010

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.


Re: [TUT]How to force a NPC to do an Animation - Vladeksh - 17.06.2010

don't work in my NPCs
Please help


Re: [TUT]How to force a NPC to do an Animation - boelie - 17.06.2010

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


Re: [TUT]How to force a NPC to do an Animation - Vladeksh - 18.06.2010

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;
}



Re: [TUT]How to force a NPC to do an Animation - Vladeksh - 18.06.2010

Help please


Re: [TUT]How to force a NPC to do an Animation - boelie - 18.06.2010

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


Re: [TUT]How to force a NPC to do an Animation - Vladeksh - 18.06.2010

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?


Re: [TUT]How to force a NPC to do an Animation - Secks - 18.06.2010

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.




Re: [TUT]How to force a NPC to do an Animation - Vladeksh - 18.06.2010

Quote:

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

how?