Each entry in Config.zones defines one anti-AI zone.
Zone Configuration Fields
Type:vector3
Purpose: Defines the center point of the zone in the GTA V world.
Usage: NPC distance to this point is used to determine whether they are inside the zone.
Radius
Type:float
Unit: meters
Purpose: Defines how far out from the center the zone extends.
Effect: Any NPC located within this horizontal radius is considered inside the zone.
Visible
Type: boolean
Purpose: Controls whether the zone is drawn visually in the world.
Typical use: For debugging or fine-tuning the area placement.
minZ and maxZ
Type: number
Purpose: Defines the vertical boundaries of the zone.
Effect:
If an NPC's Z coordinate is between minZ and maxZ, they are considered inside the zone.
Why so large?
This ensures the zone catches NPCs regardless of altitude unless you limit these values intentionally.
How the Script Works
1. Startup Check
When the resource starts or restarts:
The script scans all currently existing NPCs.
Any NPC found inside any configured zone is:
Deleted
Despawned
Removed from world population
This ensures zones are cleared immediately on load.
2. Continuous Detection
During runtime, the script continuously monitors:
NPCs walking into the zone
NPCs moving on foot into the area are instantly removed.
NPCs driving vehicles into the zone
Vehicle occupants are detected, and NPC drivers/passengers are despawned.
NPCs teleporting or spawning inside the zone
Any ped spawn event that occurs inside a zone area results in immediate despawn.
What NPCs Are Removed
The script targets:
Ambient AI pedestrians
Drivers
Parked car occupants
Scripted scenario peds
Random spawn peds
Example Zone Explained
Your provided zone:
This creates a 25m Anti-AI bubble surrounding the coordinates near Sandy Shores’ surrounding area (based on location), ensuring no NPC ever wanders, drives, or spawns there.
Andrew’s Anti-AI Zones
A FiveM script that automatically removes all NPCs from designated map areas.
Features
Removes NPCs entering the zone by walking/driving/teleporting