head-side-gearAndrew's Anti-AI Zones

Overview

Andrew’s Anti-AI Zones is a FiveM script designed to maintain AI-free areas by detecting and removing NPCs (peds) that:

  • Enter the zone by walking, driving, or teleporting

  • Spawn inside the zone

  • Already exist in the zone when the script starts or reloads

This ensures the designated area(s) remain completely free of ambient NPC activity.

The script uses simple spherical/cylindrical zone logic defined in a Config.zones table.

Configuration File Documentation

Config Table

The script uses a global configuration table named Config, which stores all zone definitions.

Structure

Config = {}
Config.zones = {
    {
        center = vector3(1805.81, 3858.15, 36.62),
        radius = 25.0,
        visible = true,
        minZ = -1000,
        maxZ = 1000,
    }
}

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

  • Removes NPCs that spawn inside the zone

  • Clears existing NPCs on resource startup

  • Supports unlimited zones

  • Optional debug visualization

Config Example

Last updated