NPC (Peds) attack together

So, i have spawn npc and they have to attack just player not together. But when peds spawned and I just make them aggressive, they shoot with another peds. So, what should i do for stop them shoot themself and just shooting me?

1 Like

Hi,

You can try this: https://runtime.fivem.net/doc/reference.html#_0xF166E48407BAC484

1 Like

Hi, i already tried this, but they are always shoot themself and me.

Did you try to don’t make them agressive with the task to shot you?

1 Like

so, should i try to turn off relationship and make just task to shooting me?

Yes, something like this.

that’s my code:

				AddRelationshipGroup(testped)
              SetRelationshipBetweenGroups(5, GetHashKey('PLAYER'), GetHashKey(testped))
              SetRelationshipBetweenGroups(5, GetHashKey(testped), GetHashKey('PLAYER'))
			   SetPedCanSwitchWeapon(testped, true)
			   			SetPedArmour(testped, 100)
						TaskCombatPed(testped, GetPlayerPed(-1), 0, 16)
			SetPedAccuracy(testped, 50)
			SetEntityMaxHealth(testped, 500)
			SetEntityHealth(testped, 500)
			SetPedSeeingRange(testped, 100.0)
			SetPedHearingRange(testped, 80.0)
			SetEntityOnlyDamagedByPlayer(testped, true)
			SetPedFleeAttributes(testped, 0, 0)
			SetPedCombatAttributes(testped, 16, 1)
			SetPedCombatAttributes(testped, 17, 0)
			SetPedCombatAttributes(testped, 46, 1)
			SetPedCombatAttributes(testped, 1424, 0)
			SetPedCombatAttributes(testped, 5, 1)
			SetPedCombatRange(testped,2)
			SetPedAlertness(testped,3)
			SetAmbientVoiceName(testped, "ALIENS")
			SetPedEnableWeaponBlocking(testped, true)
			SetPedRelationshipGroupHash(testped, GetHashKey(testped))
			DisablePedPainAudio(testped, true)
			SetPedDiesInWater(testped, false)
			SetPedDiesWhenInjured(testped, false)
			--	PlaceObjectOnGroundProperly(ped)
			SetPedDiesInstantlyInWater(testped,true)
			SetPedConfigFlag(testped,100,1)
			StopPedSpeaking(testped,true)

I think you can remove this (just comment :wink: ):

AddRelationshipGroup(testped)
SetRelationshipBetweenGroups(5, GetHashKey('PLAYER'), GetHashKey(testped))
SetRelationshipBetweenGroups(5, GetHashKey(testped), GetHashKey('PLAYER'))
TaskCombatPed(testped, GetPlayerPed(-1), 0, 16)

Just this function order your ped to attack you

1 Like

So, that’s doesn’t help, they shooting tehmself together. May be another native?

Huummm, I can’t test any script on FiveM for the moment. I can send some function, but can’t be sure ^^.

I found this: https://runtime.fivem.net/doc/reference.html#_0x7BF835BB9E2698C8 , seem to attack the closest hated, so if you’re the only one hated, should be work