01.11.2009, 22:55
(
Последний раз редактировалось Tannz0rz; 03.10.2010 в 03:40.
)
For those of you whom like to complain that NPCs don't have the potential to attack, stop complaining. You might want to edit your own script to place stationary NPCs around the server. The default way to set a NPC's position is with "/getnpc". Also, if you wish to throw off his accuracy a bit, just go to line 89 and change the dOffset value to whatever you want.
EDIT: Players can now shoot at and kill the NPC, though be warned, he has a nice chunk of hp.
What he does: he faces the closest player that is within 30 units to him, and shoots at said player.
It was requested that I simply turn this into a function, and so I did such. I've also left up the old one for those of you whom don't want to bother with the include.
Function-
CreateAttackingNPC
Create an attacking npc at a specific location.
Parameters-
npcname, the NPC you wish to make an attacking NPC
Float, the NPC's X position
Float:y, the NPC's Y position
Float:z, the NPC's Z position
Float:AttackRadius (default: 60 units), the npc's firing distance
Float:Accuracy (default: 10 degrees), the npc's firing accuracy
Example on how to use it (you MUST use a timer):
Video (sorry, no audio!):
SAMP Attacking NPC
Download (old):
Download (new):
You also need this include (a_angles):
EDIT: some people have had some problems regarding the creation of their own attacking NPCs, due to the lack of a NPC file, so I'll provide you all with one here:
Have any suggestions for any future updates? Post em' here.
Enjoy.
EDIT: Players can now shoot at and kill the NPC, though be warned, he has a nice chunk of hp.
What he does: he faces the closest player that is within 30 units to him, and shoots at said player.
It was requested that I simply turn this into a function, and so I did such. I've also left up the old one for those of you whom don't want to bother with the include.
Function-
CreateAttackingNPC
Create an attacking npc at a specific location.
Parameters-
npcname, the NPC you wish to make an attacking NPC
Float, the NPC's X position
Float:y, the NPC's Y position
Float:z, the NPC's Z position
Float:AttackRadius (default: 60 units), the npc's firing distance
Float:Accuracy (default: 10 degrees), the npc's firing accuracy
Example on how to use it (you MUST use a timer):
pawn Код:
#include <a_samp>
#include <attacking_npc>
#define FILTERSCRIPT
public OnFilterScriptInit()
{
ConnectNPC("Attack_NPC", "1");
return 0;
}
//We make sure that the NPC spawns before we make it an attacking NPC
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
if(playerid == GetPlayerID("Attack_NPC")) SetTimer("AttackNPC", 5000, 0);
}
return 0;
}
forward AttackNPC();
public AttackNPC()
{
CreateAttackingNPC("Attack_NPC", 0.0, 0.0, 0.0);
return 0;
}
Video (sorry, no audio!):
SAMP Attacking NPC
Download (old):
Download (new):
You also need this include (a_angles):
EDIT: some people have had some problems regarding the creation of their own attacking NPCs, due to the lack of a NPC file, so I'll provide you all with one here:
Have any suggestions for any future updates? Post em' here.
Enjoy.