A FiveM resource that allows police officers to interact with random pedestrian NPCs - check IDs, frisk for items, seize contraband, and make arrests. Designed for QBCore/QBX servers with a FivePD-style experience.
- What This Script Does
- Gameplay Flow
- Features
- File Structure
- Dependencies
- Configuration
- Technical Details
- Potential Improvements
- Integration with dps-ainpcs
- Installation
This script gives police officers the ability to stop and interact with any random NPC pedestrian in the world. Unlike player-to-player interactions, this creates organic police roleplay content without needing another player.
Think of it as: FivePD-style pedestrian stops for roleplay servers.
- Police officers have nothing to do when no criminals are online
- Creates realistic patrol gameplay
- Generates dynamic dispatch calls for other officers
- Provides training scenarios for new officers
┌─────────────────────────────────────────────────────────────────────────┐
│ OFFICER APPROACHES NPC │
│ (Within 20m, target prompt appears) │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ POLICE MENU │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ [👤] Check ID Card - View NPC's identification │ │
│ │ [🔍] Frisk Pedestrian - Search for items │ │
│ │ [❌] Close Menu - Release the NPC │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
│
┌───────────────┴───────────────┐
▼ ▼
┌──────────────┐ ┌──────────────┐
│ CHECK ID │ │ FRISK │
│ │ │ │
│ • Mugshot │ │ NPC puts │
│ • Name │ │ hands up │
│ • Gender │ │ │
│ │ │ 3-6 random │
│ Press ESC │ │ items from │
│ to close │ │ inventory │
└──────────────┘ └──────────────┘
│ │
▼ ▼
Return to menu ┌───────────────┴───────────────┐
▼ ▼
┌──────────────┐ ┌──────────────┐
│ LEGAL ITEMS │ │ILLEGAL ITEMS │
│ ONLY │ │ FOUND │
│ │ │ │
│ • Water │ │ • Drugs │
│ • Food │ │ • Weapons │
│ • Cigarettes │ │ • Lockpicks │
│ │ │ │
│ Return to │ │ DISPATCH │
│ menu │ │ SENT TO │
└──────────────┘ │ OTHER COPS │
└──────────────┘
│
▼
┌──────────────────────────┐
│ ARREST MENU │
│ │
│ • Click items to SEIZE │
│ • Frisk again │
│ • NEGOTIATE INTEL (NEW) │
│ • ARREST │
└──────────────────────────┘
│
┌───────────────────────────┼───────────────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ ARREST │ │ NEGOTIATE │ │ (continued) │
│ DIRECT │ │ INTEL │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
┌───────────────┴───────────────┐ ┌──────────────────────────┐
▼ ▼ │ 70% HAS INTEL │
┌──────────────┐ ┌──────────────┐ │
│ COMPLIANT │ │ RUNNER │ • Hear intel first │
│ (50%) │ │ (50%) │ • Accept deal │
│ │ │ │ • Reject & arrest │
│ NPC surrenders│ │ NPC FLEES! │ • Offer informant deal│
│ Fade to black │ │ │ │
│ Arrest done │ │ Dispatch: └──────────────────────────┘
│ │ │ "Foot Pursuit"│ │
│ Dispatch: │ │ │ ▼
│ "Arrest Made"│ │ Officer gets │ ┌──────────────┐
│ │ │ stun gun │ │ INFORMANT │
│ Jail time │ │ │ │ DEAL │
│ calculated │ │ Must taze & │ │ │
└──────────────┘ │ arrest │ │ 40% accepts │
│ │ │ Release or │
│ Dispatch: │ │ Arrest anyway│
│ "Arrest Made"│ └──────────────┘
└──────────────┘
| Feature | Description |
|---|---|
| Auto-scanning | Scans for pedestrians within 20m every 1.5 seconds |
| Network registration | NPCs are registered as network entities for sync |
| Target integration | Works with qb-target or ox_target |
| Job restriction | Only visible to players with police job |
| Feature | Description |
|---|---|
| Dynamic mugshot | Captures NPC's face using GTA's headshot system |
| Generated names | Random first/last name based on gender |
| Persistent identity | Same NPC = same name (until deleted) |
| Custom UI | Displays ID card with photo overlay |
| Feature | Description |
|---|---|
| Animations | NPC plays "hands up" animation |
| Dynamic items | Pulls from your actual inventory system |
| Legal/illegal | Items classified via config blacklist |
| Clickable seizure | Click items to take them |
| Quantity variation | Random amounts (1-5 per item) |
| Feature | Description |
|---|---|
| Conditional | Only available when contraband found |
| Two scenarios | 50% compliant, 50% runner |
| Chase mechanic | Runner must be tazed to arrest |
| Stun gun provision | Officer receives stun gun for chase |
| Event | Dispatch Sent | Priority |
|---|---|---|
| Illegal items found | "Contraband Located" | 2 |
| Suspect flees | "Foot Pursuit" | 3 |
| Arrest complete | "Arrest Made" | 1 |
| Feature | Description |
|---|---|
| Intel Negotiation | NPCs can offer information to reduce sentence |
| Dynamic Intel | Generated based on items found (drugs/weapons/gang) |
| Intel Database | All intel stored in npc_intel_reports table |
| Informant Recruitment | 40% chance NPC accepts being long-term informant |
| Release Option | Release informants without charges to maintain cover |
| Feature | Description |
|---|---|
| Arrest Records | All arrests stored in database |
| Dynamic Sentencing | Jail time based on contraband severity |
| Criminal History | ID card shows prior arrests |
| Real-Time Conversion | 1 game hour = 2 real minutes (configurable) |
| Max Sentence | 72 game hours maximum |
Sentencing Guidelines:
| Offense | Base + Bonus Hours |
|---|---|
| Weapons | +12 hours |
| Drug Bricks | +8 hours |
| Regular Drugs | +4 hours |
| Crime Tools | +6 hours |
| Feature | Description |
|---|---|
| dps-ainpcs Support | Connect to AI NPC system |
| Dynamic Dialogue | AI-generated responses based on context |
| Fallback System | Static dialogues if AI unavailable |
| Protection | Description |
|---|---|
| Server authority | All validation done server-side |
| Distance checks | Must be within 5-10m for actions |
| NPC locking | One officer per NPC |
| Net ID validation | Prevents entity spoofing |
dps-badpeds/
├── fxmanifest.lua # Resource manifest (v2.0.0)
├── config.lua # All configuration (~220 lines)
│ ├── Jail system settings
│ ├── AI integration settings
│ ├── Intel templates
│ └── Dispatch configuration
├── client.lua # Client logic (~835 lines)
│ ├── NPC detection loop
│ ├── Target registration
│ ├── Menu handling
│ ├── ID card display (with criminal history)
│ ├── Arrest scenarios
│ ├── Intel trading UI
│ ├── Informant recruitment
│ ├── Dispatch integration
│ └── AI dialogue hooks
├── server.lua # Server logic (~760 lines)
│ ├── Jail system functions
│ ├── Intel generation
│ ├── Informant management
│ ├── Database operations
│ ├── Validation functions
│ ├── NPC inventory generation
│ ├── Item seizure handling
│ ├── Arrest processing
│ └── Data cleanup
├── sql/
│ └── jail_records.sql # Database migration
├── stream/
│ └── idcard.ytd # ID card texture (106KB)
└── README.md # This file
qb-core (or qbx_core) - Framework
qb-menu - Menu UI system
qb-target OR ox_target - NPC targeting
Config.inventory = 'qs-inventory' -- Options:
-- 'qb-inventory'
-- 'qs-inventory'
-- 'ox_inventory'Config.dispatch.resource = 'wasabi_mdt' -- Options:
-- 'wasabi_mdt'
-- 'ps-dispatch'
-- 'cd_dispatch'-- Target & Inventory
Config.target = 'qb-target'
Config.inventory = 'qs-inventory'
-- Dispatch Integration
Config.dispatch = {
enabled = true,
resource = 'wasabi_mdt',
illegalItemsFound = { enabled = true, priority = 2, ... },
suspectFleeing = { enabled = true, priority = 3, ... },
arrestMade = { enabled = true, priority = 1, ... },
}
-- NPC Inventory
Config.npcItemCount = { min = 3, max = 6 }
Config.itemQuantity = { min = 1, max = 5 }
-- Illegal Items (triggers arrest option)
Config.illegalItems = {
"joint", "cokebaggy", "weapon_pistol", "lockpick", ...
}
-- Excluded Items (won't spawn on NPCs)
Config.excludedItems = {
"phone", "police_badge", "weapon_stungun", ...
}
-- Name Generation
Config.malefirstNames = { "John", "Michael", ... }
Config.femalefirstNames = { "Emily", "Madison", ... }
Config.lastNames = { "Smith", "Johnson", ... }- On resource start: Server calls
exports['qs-inventory']:GetItemList() - Filtering: Removes items in
excludedItemslist - On frisk: Generates 3-6 random items from filtered pool
- Classification: Checks against
illegalItemsblacklist - Persistence: Inventory stored server-side until NPC deleted
CLIENT SERVER
│ │
│ pedInteraction:request ────────► │ Validate NPC, lock it
│ ◄──────── pedInteraction:approved │
│ │
│ addinventory ──────────────────► │ Generate/return items
│ ◄──────────────────────── addmenu │
│ │
│ npc:seizeItem:server ──────────► │ Give item to player
│ ◄───────────── npc:refreshInventory│
│ │
│ arrestnpc ─────────────────────► │ Remove stun gun, cleanup
│ ◄────────────────────── deletenpc │
activeInteractions[playerSource] = netId -- Who's talking to which NPC
npcInventories[netId] = { items... } -- NPC's generated inventory
npcNames[netId] = { first, last, gender } -- NPC's generated identity
npcIllegal[netId] = true/false -- Has illegal items?
npcLocks[netId] = playerSource -- Who has this NPC locked?| Feature | Description | Effort |
|---|---|---|
| Warrant Check | Query MDT for active warrants on NPC name | Medium |
| Vehicle Stops | Pull over NPCs in vehicles, search car | High |
| Multiple Jobs | Support sheriff, state police, etc. | Easy |
| ox_lib Menu | Modern menu instead of qb-menu | Easy |
| Feature | Description | Effort |
|---|---|---|
| Item Weighting | Illegal items rarer than legal | Easy |
| NPC Reactions | Nervous behavior if carrying drugs | Medium |
| Citation System | Tickets for minor offenses | Medium |
| Evidence Bagging | Package items for MDT cases | Medium |
| Chase Improvements | NPC steals car, more pursuit variety | High |
| Feature | Description | Effort |
|---|---|---|
| Area-based items | Gang areas = more weapons | Easy |
| Time-based | More crime at night | Easy |
| K9 Integration | Dog sniffs out drugs | High |
| NPC Memory | Remember previous interactions | Medium |
Try the dps-ainpcs script, it creates AI-powered NPCs with conversations, trust systems, and intel trading. These two scripts complement each other:
- dps-badpeds: For random street NPCs (any pedestrian)
- dps-ainpcs: For specific configured AI NPCs (informants, dealers)
- Police can frisk random people, but AI NPCs have deeper interaction
Add police frisk capability to dps-ainpcs NPCs:
-- In dps-ainpcs, add to NPC options:
{
label = "Frisk",
icon = "fas fa-search",
job = "police",
onSelect = function(npc)
-- Trigger dps-badpeds's frisk system
-- Or implement custom frisk for AI NPCs
end
}| Feature | Description |
|---|---|
| AI Resistance | AI NPCs could argue, demand warrant, or lie |
| Trust Impact | Frisking an informant damages trust relationship |
| Intel from Arrest | Arrested NPC might give up information |
| Bribery | NPC offers money to avoid arrest |
| Lawyer Request | "I want my lawyer" dialogue option |
Both scripts could share:
- NPC identity (same name system)
- Criminal history
- Trust/reputation
- MDT records
-
Download and place in resources folder
-
Run SQL Migration (if using jail system):
-- Run the contents of sql/jail_records.sql in your database -- Creates: npc_jail_records, npc_informants, npc_intel_reports tables
-
Add to server.cfg:
ensure qb-core ensure qb-menu ensure qb-target ensure qs-inventory ensure oxmysql # Required for jail system ensure wasabi_mdt # Optional for dispatch ensure dps-ainpcs # Optional for AI dialogue ensure dps-badpeds
-
Configure
config.lua:- Set target system (
qb-targetorox-target) - Set inventory system (
qs-inventory,qb-inventory,ox_inventory) - Enable/disable jail system
- Enable/disable AI integration
- Adjust illegal items list
- Configure dispatch settings
- Customize intel templates
- Set target system (
-
Restart server or
ensure dps-badpeds
-- config.lua minimal changes
Config.target = 'qb-target'
Config.inventory = 'qs-inventory'
Config.jailSystem.enabled = false -- Disable if not using database
Config.aiIntegration.enabled = false| Issue | Solution |
|---|---|
| Target not appearing | Check job is police, ensure qb-target running |
| Items not generating | Verify inventory resource name in config |
| "Item does not exist" | Item spawn code not in your inventory |
| Dispatch not sending | Check wasabi_mdt is running, dispatch enabled |
| NPC not responding | Another officer may have it locked |
- Original Author: AlexCarton
- Modifications: Claude (Anthropic) - dispatch integration, qs-inventory support, item seizure, security improvements
- Framework: QBCore/QBX Team
Free to use and modify for personal or server use. Redistribution or resale requires permission from the author.