Live
Forensics and crime scenes
A detective system for a police roleplay server: bodies that persist, evidence that holds up, and case files detectives can search. I inherited it half-built and broken, and turned it into a working system.
- Role
- Took over an unfinished plugin, then rebuilt, extended and maintained it
- Stack
- Lua (GLua), NutScript, MySQL
- Context
- Police and criminal roleplay on Diverge Networks
- Status
- Live, in use since December 2024
The problem
When I joined Diverge Networks, the server already had a forensics plugin, written by an earlier developer and never finished. Bodies duplicated or vanished, evidence didn’t survive a map change, and some fingerprints couldn’t be lifted at all. Police and criminal roleplay leaned on it anyway.
Over nearly two years and about 70 commits, I turned it into the system the roleplay needed: crime scenes that persist, evidence that holds up, and case files detectives can actually work from. I kept the original author’s credit in the code.
Bodies and crime scenes
- Bodies persist where the person died, across restarts and map changes, with a recorded time of death.
- Inspecting a body shows how the person died, their recent wounds and the weapons they were carrying at the time. Hunger and withdrawal no longer show up as violent injuries.
- Criminals can dispose of a body: dismember it into separate body-part items, burn it with gasoline so the corpse visibly chars, or zip it into a body bag. Bodies taken back out of a bag keep everything they had.
- Dragging a body slows you down, and the slowdown always clears, even if the body is deleted mid-drag.
- The killer’s faction is logged on the body. Only the police and that faction can move it, and only that faction can sweep up the casings, so bystanders can’t destroy the evidence out of character.
- Blood can be cleaned up through a short minigame, and blood older than seven days fades away.
- Staff can create the body for a past death after the fact.
Video coming soon
A detective at a test crime scene: inspecting the body, bagging a bullet casing, then lifting a fingerprint onto a card.
assets/projects/forensics/crime-scene.mp4 (20 to 30 seconds)
Screenshot coming soon
The inspect-body panel on a test character, showing time of death, wounds and the weapons carried.
assets/projects/forensics/inspect-corpse.png (tight crop to the panel)
Video (optional) coming soon
A criminal burning a body with gasoline, or zipping it into a body bag.
assets/projects/forensics/body-disposal.mp4 (about 15 seconds)
Evidence
- Fingerprints are left on items when they’re picked up or dropped, and on doors, unless you wear gloves.
- Prints on items fade after a week and on doors after an hour, and the same person can only leave one print per item per hour, so items don’t fill up with noise.
- Detectives lift prints with kits and cards, test hands for gunshot residue, mark scenes with numbered markers, police tape and chalk outlines, and collect bullet casings and blood.
- Regular officers can seal evidence in evidence bags, so casings reach a detective with their prints intact.
- Used-up kits and empty cases can be disposed of instead of cluttering inventories.
Screenshot coming soon
A fingerprint card after lifting a print, with its edited backing card.
assets/projects/forensics/fingerprint-card.png (tight crop)
Case files and the database
- Every sample goes into a forensics database that detectives can search, compare against and export reports from.
- Detectives open case files and attach evidence to them, by case number or by part of the case name.
- Case reports are items: copying or returning one keeps it linked to the underlying case, and edits to a fingerprint card’s backing card are stored in the database, so they survive being returned and pulled again.
- Recent cases are worked out on the server, and searches page through results so the lists stay usable as the database grows.
Screenshot coming soon
The forensics database with search results, filled with test data.
assets/projects/forensics/case-database.png (tight crop to the panel)
Screenshot coming soon
A detective case file with evidence attached, test data only.
assets/projects/forensics/case-file.png (tight crop to the panel)
Built for a live server
- Lifting a print needs a one-time authorisation from the server that’s tied to that card and that item, expires after a minute, and only works within arm’s reach. The print itself is looked up on the server, never taken from the request.
- Edits to a backing card only accept known fields, each capped in length, and are stored on the server.
- Every action checks the player’s forensics level, from civilian to detective to forensic expert, on the server.
- Scenes are saved to MySQL through the shared plugin data store, with an autosave every five minutes, replacing the file saves that lost entities on map changes.
- I built internal tools for testing scenes quickly and for debugging where bullet casings land.
Code excerpt coming soon
Lifting a print: the one-time server authorisation, the distance check and the server-side lookup.
assets/excerpts/lift-print.lua
Still being untangled
Some of the original design is still underneath, and it still surfaces as the occasional odd bug. Each fix is a chance to replace another piece of it.