Notice: Failed to invoke Pygments: [Called from MediaWiki\SyntaxHighlight\SyntaxHighlight::highlightInner in /home/pi/www/gtac/wiki/wiki/extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlight.php at line 334] in /home/pi/www/gtac/wiki/wiki/includes/debug/MWDebug.php on line 507
ScriptingExamples/PedAttackPlayer - GTA Connected

ScriptingExamples/PedAttackPlayer

Revision as of 05:34, 5 September 2025 by Vortrex (talk | contribs) (Created page with "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.<br> {{JSCode|1= ped.setThreatSearch(1); // To make the ped target the player ped.heedThreats = true; // To enable attacking threats }} == Notes == * A list of ped [https://wiki.gtaconnected.com/Defines/III#GTA_III_-_Threat_Defines threat types for GTA 3]. Vice City threats aren't documented, but they're the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.