Kolopsel Posted June 25, 2017 Share Posted June 25, 2017 Hello, so this is the continuation of "How to let a ped attack the Player or another Ped ? [C#] " The Problem is, that the ped ive created attacks itselft instead of attacking other peds. It would be nice if you could help me. My Code : Ped player = Game.Player.Character; GTA.Math.Vector3 mySpot = player.Position.Around(5.0F); Ped angryPed = World.CreatePed(PedHash.Bankman01, mySpot); Ped targetPed = World.GetClosestPed(angryPed.Position, 12f); angryPed.Task.FightAgainst(targetPed); Thanks for reading ! - Kolopsel Link to comment Share on other sites More sharing options...
sjaak327 Posted June 25, 2017 Share Posted June 25, 2017 hahah a suicide ped, nice find ins1de 1 Link to comment Share on other sites More sharing options...
Scriptkiddy1337 Posted June 25, 2017 Share Posted June 25, 2017 i don't know how to fix it in C#, for ussual there is a way to iterate more peds. But this code seems to does exactly what if have to do ^^ Ped angryPed = World.CreatePed(PedHash.Bankman01, mySpot); // you spawn a Ped herePed targetPed = World.GetClosestPed(angryPed.Position, 12f); // and want the closest Ped to the Coords of your created Peds// the result will be of course targetPed == angryPed because, it's obviously the closest Ped in this Coords ^^2 Ways to fix it would be to find the way to iterate them in C# or you use the coords relative to yours Ped targetPed = World.GetClosestPed(mySpot, 12f);and in anycase make sure, you don't found or own Ped if (Game.Player.Character != targetPed && angryPed != targetPed) angryPed.Task.FightAgainst(targetPed); Link to comment Share on other sites More sharing options...
Kolopsel Posted June 25, 2017 Author Share Posted June 25, 2017 (edited) i don't know how to fix it in C#, for ussual there is a way to iterate more peds. But this code seems to does exactly what if have to do ^^ Ped angryPed = World.CreatePed(PedHash.Bankman01, mySpot); // you spawn a Ped herePed targetPed = World.GetClosestPed(angryPed.Position, 12f); // and want the closest Ped to the Coords of your created Peds// the result will be of course targetPed == angryPed because, it's obviously the closest Ped in this Coords ^^2 Ways to fix it would be to find the way to iterate them in C# or you use the coords relative to yours Ped targetPed = World.GetClosestPed(mySpot, 12f);and in anycase make sure, you don't found or own Ped if (Game.Player.Character != targetPed && angryPed != targetPed) angryPed.Task.FightAgainst(targetPed); Thanks ! Edited June 25, 2017 by Kolopsel Link to comment Share on other sites More sharing options...
ins1de Posted June 25, 2017 Share Posted June 25, 2017 (edited) Hello, so this is the continuation of "How to let a ped attack the Player or another Ped ? [C#] " The Problem is, that the ped ive created attacks itselft instead of attacking other peds. It would be nice if you could help me. My Code : Ped player = Game.Player.Character; GTA.Math.Vector3 mySpot = player.Position.Around(5.0F); Ped angryPed = World.CreatePed(PedHash.Bankman01, mySpot); Ped targetPed = World.GetClosestPed(angryPed.Position, 12f); angryPed.Task.FightAgainst(targetPed); Thanks for reading ! - Kolopsel This was happened because the function World.GetClosestPed returned the closest ped from a position. Therefore, your ped was always the closest ped returned because he has the smallest distance to the position. To avoid this problem, you can get a list of close peds, iterate through the list and always verify that the current processed ped is not the target ped. (Scriptkiddy1337's solution) No more suicidal peds Edited June 25, 2017 by ins1de Link to comment Share on other sites More sharing options...