Friday, November 26, 2010

SAMP Scripting Tutorial: Add NPCs | Record NPC Paths | Play Animations

Here is the code

#include <a_npc>
#define rec "npc_walking"
#define onfoot 2

main(){}

public OnRecordingPlaybackEnd() StartRecordingPlayback(onfoot,rec);
public OnNPCSpawn()
{
 SetMyPos(1521.5752,-1668.3490,13.5469);
 StartRecordingPlayback(onfoot,rec);
}
public OnPlayerStreamIn(playerid)
{
 SetTimer("SendCmd",3000,true);
}

forward SendCmd();
public SendCmd()
{
 SendCommand("/anim");
 return 1;
}[/cpp]
[cpp title="tutorial.pwn"]
// OnPlayerText
if(strcmp(cmdtext,"/anim",true)==0)
{
 ApplyAnimation(playerid,"ped","FALL_collapse",4.0,0,0,0,0,0);
 return 1;
}

// OnGameModeInit
ConnectNPC("Dave","npc_walk");

2 comments: