[FS/INC] Attacking NPCs
#1

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 Код:
#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.
Reply
#2

damn dude, this is awesome.

It's great to see people are using NPC's to their full advantages
Reply
#3

Sexy job! i likie
Reply
#4

Good job!! Now we need a way to kill npcs with guns.
Reply
#5

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.
Reply
#6

Main post updated, the NPC is now killable as well.
Reply
#7

FUCK! EPIC!

Iґll be using THAT for sure. Thanks!
Reply
#8

Dude you are an epic scripter you should consider selling your scripts
Reply
#9

Quote:

Dude you are an epic scripter you should consider selling your scripts

True, I would have bought that.
Reply
#10

Can someone mirror this please
Reply
#11

Thanks for the comments all.
Reply
#12

Iґve made one working a bit different, but acting pretty similar to yours. Thanks for the idea!
Reply
#13

Hmm, I MUST look into this, this looks very interesting. Nice work, indeed.

Would you like a mirror?
Reply
#14

Gonna use this =)
Reply
#15

this is awesome. nice job
Reply
#16

Awesome! I'm downloading this now.
Reply
#17

Wow great work, maybe this script could be edited to see if a certain player is near that they may pass him without him attacking... hmm. RP IDEA!
Reply
#18

Quote:
Originally Posted by Tez
Wow great work, maybe this script could be edited to see if a certain player is near that they may pass him without him attacking... hmm. RP IDEA!
Its doable. Shouldn't take more than 1 line of code, lol. Could be used for guards at police departments and so forth.
Reply
#19

You mind making a new link and taking away a .7z file so I may download?
Kthanx.
Reply
#20

Great job! It is very good! Thank you!
But Link is dead Upload www.solidfiles.com please
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)