Hmm,npc attacking the other NPC instead me. - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Hmm,npc attacking the other NPC instead me. (
/showthread.php?tid=258611)
Hmm,npc attacking the other NPC instead me. -
SkizzoTrick - 31.05.2011
pawn Code:
new Float:x,Float:y,Float:z;
new Float:px,Float:py,Float:pz;
for(new p = 0;p < MAX_PLAYERS;p++)
{
for_npcs(i)
{
if(guard[i] == 1)
{
GetNPCPos(i,x,y,z);
GetPlayerPos(p,px,py,pz);
if(IsPlayerInRangeOfPoint(p,12.0,x,y,z))
{
NPC_ShotAt(i,px,py,pz);
}
}
}
}
So this is what i mean,im trying to make a function that will make the NPC attack all the players in range but:
I also made a function that makes a NPC protect me and his coming with me anywhere but now,i have a problem.
If i spawn a Guard NPC,his not going to shoot me.If i also spawn a Protecting NPC wich will follow me,the Guard will attack him instead me,lol.
Why?
Re: Hmm,npc attacking the other NPC instead me. -
PCheriyan007 - 31.05.2011
Since I'm kind of new I can't really understand your function too well but try changing it so the NPC will search for other players within range rather than NPC's. Also try using Foreach it makes things a tad simpler.
Re: Hmm,npc attacking the other NPC instead me. -
SkizzoTrick - 31.05.2011
Quote:
Originally Posted by PCheriyan007
Since I'm kind of new I can't really understand your function too well but try changing it so the NPC will search for other players within range rather than NPC's. Also try using Foreach it makes things a tad simpler.
|
I tried that too but unfortunatelly it is not working...
Re: Hmm,npc attacking the other NPC instead me. -
SkizzoTrick - 31.05.2011
Foreach worked :X:X
Thank you Chariyan,moderators can close this topic,thank you.
Re: Hmm,npc attacking the other NPC instead me. -
PCheriyan007 - 31.05.2011
Your welcome, just trying to help.