Cops That See.
Not Cops That Teleport.
rde_aipd is a true line-of-sight AI police system for ox_core — cops only react to what they can actually see, with dynamic threat assessment, a physics-based tackle, and a realistic witness system with panic delay and night modifiers. StateBag-synced, Nostr-logged, production-ready.
Overview
Every other police script is either paid, ESX/QB-only, or a laggy mess with braindead AI that just runs straight at you. rde_aipd is built ox_core-native with true line-of-sight detection, dynamic threat calculation per unit, and a realistic witness/911 pipeline instead of instant omniscient cops.
Why this over other police scripts
| Other Police Scripts | rde_aipd |
|---|---|
| Static wanted levels | Dynamic, decay-based wanted system |
| Dumb AI that just runs at you | True line-of-sight AI with threat assessment |
| Discord webhooks (deletable, bannable) | Decentralized Nostr logging — permanent |
| 0.5ms+ idle resource usage | < 0.01ms idle |
Quick Start
-- Dependencies first — order matters!
ensure oxmysql
ensure ox_lib
ensure ox_core
ensure ox_inventory
-- Optional: Nostr logging (highly recommended)
ensure rde_nostr_log
-- The AI police system
ensure rde_aipd
No SQL import needed — tables auto-create on first run. Already on a previous version? Just git pull — v1.0.6-alpha is a drop-in replacement, same config structure, same DB schema.
Configuration
Witness System
Config.WitnessSystem = {
fieldOfView = 240.0, -- NPC cone of vision (degrees)
proximityGraceDistance = 8.0, -- "heard it" radius bypassing FOV+LOS
intimidationDistance = 8.0, -- walk toward witness → they flee, no 911
panicDelay = { min=1500, max=3500 },
nightTimeModifier = 0.60, -- phone chance multiplier at night
combatSuppression = true, -- active gunfire suppresses witness calls
}
Tackle System
Config.CopTackle = {
sprintTime = 300, -- sprint windup before impact (ms)
playerRagdollMin = 3500, -- player stays down this long (ms)
tackleForce = 8.0, -- impact force on player ped
triggerDistance = 4.5, -- max distance for tackle (m)
}
Nostr Logging
First-class rde_nostr_log integration — every critical event is logged to the decentralized Nostr network, permanent and cryptographically signed.
| Event | Nostr Tag |
|---|---|
| Wanted level change | wanted_set |
| Player arrested | player_arrested |
| Crime committed | crime_detected |
| Officer killed | officer_down |
| Player surrenders / escapes | player_surrendered / player_wanted |
Disable completely with Config.Nostr.enabled = false — zero overhead, zero side effects.
Exports
| Export | Side | Returns |
|---|---|---|
| getWantedLevel() | Client | number |
| copsCanSeePlayer() | Client | boolean |
| getPlayerThreatLevel() | Client | number (0-100) |
| getPlayerFatigue() | Client | number (0-100) |
| setWantedLevel(n) | Client | — |
| surrender() | Client | — |
| LogCrime(type, coords, witnessed) | Client | — |
Debug Commands
Enable with set police_debug "true" in server.cfg.
| Command | Description |
|---|---|
| debugpolice | Dump full system state to console |
| testwanted [1-5] | Set wanted level instantly |
| testwitness [TYPE] | Force the full witness/911-call flow |
| clearcops | Despawn all pursuing units |
Common Pitfalls
Cops don't leave the minimap after wanted clears
Blip removal happened in an async thread that ran one tick after ClearAllUnits().
Fix: blips and tasks are now cleared synchronously in the same frame (v1.0.6-alpha).
Cops drive toward the player after wanted clears
Departure direction was cache.coords + random_angle × 500 — a random angle could point directly at the player.
Fix: departure is now always computed as the exact opposite vector from the player.
No witnesses / cops never spawn
Older builds used IsPedFleeing() as a hard filter — GTA sets all nearby NPCs to flee on crime, guaranteeing zero witnesses.
Fix: FOV/LOS-based witness detection replaces the flee-state filter in v1.0.6-alpha.
Tackle doesn't feel physical
The original tackle lacked directional momentum.
Fix: now uses the cop's forward vector + ApplyForceToEntity, with a sprint windup and asymmetric ragdoll durations (cop recovers faster, trained).
FAQ
Does this require rde_nostr_log?
No — it's optional. Without it, the system continues to work exactly the same, just without decentralized logging.
How many wanted levels are there?
6 — from a minor warrant up to maximum response with helicopters and roadblocks. Decay only happens when no officer has eyes on you.
Can admins be exempt from wanted?
Yes — set Config.AdminSettings.exemptFromWanted = true.
Changelog
Complete witness system rewrite, cop despawn race condition fix, physics-based tackle with forward-vector momentum.
Fixed truncated Debug(...) calls that broke Lua parsing on resource start.