Ped Attack Player Example

From GTA Connected
Revision as of 05:34, 5 September 2025 by Vortrex (talk | contribs)
Jump to navigation Jump to search


For GTA III, Vice City, and San Andreas you can use natives or the GTAC functions to set a ped to consider something as a threat, and the ped will target/attack it.

ped.setThreatSearch(1); // To make the ped target the player
ped.heedThreats = true; // To enable attacking threats

Notes

  • A list of ped threat types for GTA 3. Vice City threats aren't documented, but they're the same except for the gangs.
  • You can define multiple threats separated by a bitwise OR. Example: ped.setThreatSearch(1|64|1048576) would make the ped attack the player, cops, and anybody else that has a gun.
  • For attacking players, the ped will only attack it's syncer. If you need to change the player that the ped attacks, change the syncer then send a network event to the new syncer to tell it to set the player as a threat to update it.
  • If you set a ped's threat but the ped.heedThreats is disabled (false), the ped will NOT attack threats.