Make sure the closest ped isn't the player's character
-
Does anyone know how to get to the closest ped and make sure its NOT the players character? I need it for a mod I am working on and I need to kill the closest ped but it keep getting the player when no other ped is around the player
-
I have a question can these mods work on ps4
-
@NotCrunchyTaco
I have a question can these mods work on ps4
-
- Don't hijack threads.
- No, it won't work. Console modding is not allowed to discuss in this forum.
-
Any halp?
-
Maybe something like this?
Ped getClosestPed(Vector3 position, float radius) { Ped[] peds = World.GetNearbyPeds(position, radius); foreach (Ped p in peds) { if (p != Game.Player.Character) { return p; } else { continue; } } return null; }
And in your OnTick you can call it like this:
try { if (Game.IsControlPressed(2, GTA.Control.Sprint)) { Ped closestPed = getClosestPed(player.Position, 5f); if (closestPed.Exists() && closestPed != null) { closestPed.ApplyForce(closestPed.UpVector * 1, closestPed.ForwardVector * 100f); } } } catch { UI.ShowSubtitle("No peds in area"); }
It doesn't seem to always get the absolute closest ped occasionally
-
@stillhere thanks I'll see what I can do. I have a way to get the ped directly in front of you