RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Gameplay AchievementGameplay CityDiscoverForce FieldGarage ModeMarker InteractionParking SystemGameplay Playmode MarkersGameplay PoliceGameplay RallyGameplay Rally LoopGameplay Raw POIsGameplay Skidpad TestSpeed Trap LeaderboardsSpeed Traps and CamerasGameplay StatisticsTaxi Ride SystemTraffic SystemVehicle PerformanceWalking

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsgameplay

Gameplay Police

Manages police pursuit logic including suspect tracking, arrest/evade timers, roadblock placement, and pursuit mode escalation. Tightly integrated with the traffic system.

Manages police pursuit logic including suspect tracking, arrest/evade timers, roadblock placement, and pursuit mode escalation. Tightly integrated with the traffic system.


Public API

FunctionSignatureReturnsDescription
M.setPursuitMode(mode, targetId, policeIds)nilSets pursuit mode: -1=busted, 0=off, 1-3=pursuit level
M.setPursuitVars(data)nilMerges a table of pursuit config overrides; nil resets to defaults
M.getPursuitVars()tableReturns the current pursuit variables
M.getPursuitData(id?)tableReturns pursuit data for a vehicle (defaults to player)
M.getPoliceVehicles()tableReturns map of police vehicle IDs → traffic data
M.getNearestPoliceVehicle(targetId, isVisible, isUsable)id, dist, interDistNearest active police vehicle to a target
M.isVehicleInPursuit(id, targetId?)state, isPoliceWhether vehicle is in active pursuit
M.setSuspect(id)nilChanges a traffic vehicle's role to suspect
M.setSuspectTimer(time?)nilSets time until next suspect is queued
M.arrestVehicle(id, showMessages)nilInstantly arrests a vehicle
M.evadeVehicle(id, showMessages)nilInstantly marks a vehicle as evaded
M.releaseVehicle(id, showMessages)nilUnfreezes a vehicle after arrest
M.setupPursuitGameplay(suspectId, policeIds, options)boolHelper to configure pursuit gameplay scenario
M.insertProp(propId)nilAdds a prop vehicle for roadblocks
M.removeProp(propId)nilRemoves a prop from the roadblock pool
M.setPropsActive(active, reset)nilActivates/deactivates all police props
M.checkRoadblock(vehIds, rbWidth, useLength)validIds, totalLengthChecks which vehicles fit in a roadblock
M.placeRoadblock(vehIds, pos, rot, placeData)nilPlaces a roadblock with vehicle transforms

Hooks

HookPurpose
M.onTrafficActionTracks police role changes
M.onTrafficVehicleAddedRegisters new police vehicles
M.onTrafficVehicleRemovedUnregisters removed police vehicles
M.onTrafficStartedLogs police/prop count at traffic start
M.onTrafficStoppedClears police vehicle table
M.onVehicleSwitchedTransfers pursuit state when switching vehicles
M.onVehicleResettedManages random suspect spawning on vehicle reset
M.onClientEndMissionClears state on mission end
M.onUpdateMain per-frame pursuit logic
M.onSerialize / M.onDeserializedPersistence of pursuit vars and props
M.getPoliceVars()
M.setPoliceVars(data)

Internals

Default Pursuit Variables

VariableDefaultDescription
scoreLevels{100, 500, 2000}Score thresholds for pursuit levels 1-3
strictness0.5Detection sensitivity for infractions
arrestTime5Seconds stationary near police to arrest
evadeTime45Seconds out of range to evade
arrestRadius20Distance for arrest check
evadeRadius80Distance for evade check
suspectFrequency0.5Rate of random suspect spawning
roadblockFrequency0.5Roadblock spawn rate (0 disables)
useVisibilitytrueEnable line-of-sight checks
autoReleasetrueAuto-release after arrest countdown

How It Works

  1. Sight tracking: Each frame, sightValue accumulates based on nearest police distance and strictness; policeVisible flips at 0.5
  2. Score escalation: Pursuit score increases from infractions and time in pursuit; crossing scoreLevels thresholds escalates pursuit.mode
  3. Arrest: When both suspect and nearest police are stopped within arrestRadius for arrestTime seconds, the suspect is arrested
  4. Evade: When suspect is beyond evadeRadius for evadeTime seconds, they evade
  5. Roadblocks: At pursuit level 3, out-of-sight police are repositioned ahead of the suspect using placeRoadblock
  6. Random suspects: AI vehicles are periodically tagged as suspects based on suspectFrequency and a cooldown timer

Usage Examples

-- Start a pursuit against the player at level 2
gameplay_police.setPursuitMode(2)

-- Customize pursuit variables
gameplay_police.setPursuitVars({ arrestTime = 10, evadeTime = 30 })

-- Setup a scripted pursuit with specific vehicles
gameplay_police.setupPursuitGameplay(suspectId, {policeId1, policeId2}, { pursuitMode = 3 })

-- Check if player is being pursued
local inPursuit, isPolice = gameplay_police.isVehicleInPursuit()

Notes

  • M.enabled field can be set to false to disable all runtime police logic
  • setPoliceVars / getPoliceVars are aliases for setPursuitVars / getPursuitVars
  • Pursuit hooks: onPursuitAction(targetId, action, pursuit) and onPursuitModeUpdate(targetId, {mode})

See Also

  • Gameplay Achievement - Related reference
  • Gameplay City - Related reference
  • discover - Discover / Experience System - Related reference
  • Gameplay Systems Guide - Guide

Gameplay Playmode Markers

Clusters POI data into playmode marker groups (missions, parking, zones, walking, gas stations, drift lines, etc.) and provides spatial queries via a KD-tree for efficient visibility lookups.

Gameplay Rally

Main extension for the rally gameplay system. Manages rally mission loading/unloading, co-driver timing, recce app, rally toolbox debug UI, and integration with race pathnode events.

On this page

Public APIHooksInternalsDefault Pursuit VariablesHow It WorksUsage ExamplesNotesSee Also