SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filter Scripts and Includes

Reply
 
Thread Tools Display Modes
Old 01/11/2009, 10:55 PM   #1
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 294
Default [FS/INC] Attacking NPCs

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):
pawn Code:
#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&#39;ll provide you all with one here:


Have any suggestions for any future updates? Post em&#39; here.

Enjoy.
__________________
Tannz0rz is offline   Reply With Quote
Old 01/11/2009, 10:58 PM   #2
joemomma53
Gangsta
 
Join Date: Jul 2007
Posts: 654
Default Re: [FS] Attacking NPCs

damn dude, this is awesome.

It's great to see people are using NPC's to their full advantages
joemomma53 is offline   Reply With Quote
Old 01/11/2009, 11:01 PM   #3
SergiKirov
Huge Clucker
 
Join Date: Feb 2009
Posts: 271
Default Re: [FS] Attacking NPCs

Sexy job! i likie
SergiKirov is offline   Reply With Quote
Old 01/11/2009, 11:02 PM   #4
[TG]Chase
Big Clucker
 
Join Date: Jun 2006
Posts: 57
Default Re: [FS] Attacking NPCs

Good job!! Now we need a way to kill npcs with guns.
[TG]Chase is offline   Reply With Quote
Old 01/11/2009, 11:07 PM   #5
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 294
Default Re: [FS] Attacking NPCs

Quote:
Originally Posted by Chaser98
Good job!! Now we need a way to kill npcs with guns.
Good suggestion. I'll begin working on that.
__________________
Tannz0rz is offline   Reply With Quote
Old 01/11/2009, 11:40 PM   #6
Tannz0rz
Huge Clucker
 
Tannz0rz's Avatar
 
Join Date: Dec 2007
Posts: 294
Default Re: [FS] Attacking NPCs

Main post updated, the NPC is now killable as well.
__________________
Tannz0rz is offline   Reply With Quote
Old 02/11/2009, 06:54 AM   #7
Striker_Moe
Gangsta
 
Join Date: Apr 2009
Posts: 626
Default Re: [FS] Attacking NPCs

FUCK! EPIC!

I´ll be using THAT for sure. Thanks!
Striker_Moe is offline   Reply With Quote
Old 02/11/2009, 07:01 AM   #8
mini-d
Huge Clucker
 
Join Date: May 2008
Posts: 242
Default Re: [FS] Attacking NPCs

Dude you are an epic scripter you should consider selling your scripts
mini-d is offline   Reply With Quote
Old 02/11/2009, 07:02 AM   #9
Striker_Moe
Gangsta
 
Join Date: Apr 2009
Posts: 626
Default Re: [FS] Attacking NPCs

Quote:
Dude you are an epic scripter you should consider selling your scripts
True, I would have bought that.
Striker_Moe is offline   Reply With Quote
Old 02/11/2009, 09:12 AM   #10
Matthew_Murdoch
Huge Clucker
 
Join Date: Oct 2007
Posts: 469
Default Re: [FS] Attacking NPCs

Can someone mirror this please
Matthew_Murdoch is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
No NPCs regdude Server Support 6 08/07/2010 05:54 PM
Lol no stop attacking for me XD 02manchestera Everything and Nothing 3 27/03/2010 11:14 AM
[Solved]How the hell do i make attacking turfs -->> click for more info <--- Studio Scripting Discussion 4 15/07/2009 09:20 AM
[HELP] BAD RCON ATTACKING MY SERVER!!! chenza Server Support 7 18/02/2009 05:12 AM
MY SERVER IS ATTACKING! HELP ME Alexan Server Support 17 03/02/2009 12:48 PM


All times are GMT. The time now is 02:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.