The Ambulance
That Actually Arrives.
rde_aimd is the world's first open-source advanced death system for ox_core — realistic bleedout with 6 injury types, a cinematic death camera, and an AI ambulance with a 3-layer "Grass Fix" so it never circles a road forever when you die off-road.
Overview
rde_aimd (AI Medical Department) is a complete, production-ready death and revival system for ox_core. It provides the deathSystem resource interface — other scripts like rde_aipd depend on it via fxmanifest.lua.
Why this over paid/legacy death systems
| Paid / Legacy Systems | rde_aimd |
|---|---|
| ESX/QB only or Tebex locked | Pure ox_core, zero legacy dependencies |
| Ambulance circles roads forever | Grass Fix forces off-road arrival |
| Instant despawn after revive | Doctor walks back, drives away naturally |
| No DB persistence | isDead bulletproof DB sync — survives restarts |
Quick Start
-- required: tells ox_core to disable its built-in death handling
setr ox:deathSystem false
ensure oxmysql
ensure ox_lib
ensure ox_core
ensure ox_inventory
ensure rde_aimd
add_ace group.admin rde.admin allow
setr ox:deathSystem false is required. Without it, ox_core's built-in death handling and rde_aimd fight over death events and you get broken behavior.
No SQL imports needed — tables auto-create on first run.
Configuration
Config.Death = {
respawnTime = 120, -- seconds until hospital respawn unlocks
bleedoutRate = 0.3, -- blood loss per second (base)
ragdollInterval = 3000, -- re-apply ragdoll every N ms
spawnProtectionTime = 10000, -- ms of protection after login/respawn
}
Config.Doctor = {
baseCost = 750, -- base fee in dollars
distanceCostPerKm = 50,
callCooldown = 5, -- seconds between calls (anti-spam)
forcedArrivalDist = 80.0, -- 🌿 Grass Fix threshold, in meters
driving = { speed = 45.0, style = 786468 }, -- emergency: runs red lights
}
The Grass Fix — How It Works
GTA's vehicle pathfinder is road-only. If a player dies on grass, in a park, on a beach, or on any off-road terrain, a standard ambulance will circle the nearest road endlessly. rde_aimd solves this with a 3-layer system:
| Layer | What it does |
|---|---|
| 1. Road-Node Target | Ambulance drives toward the nearest road node adjacent to the player via GetClosestVehicleNode(), not the player's exact coords |
| 2. Stuck-Detection | Every 800ms, checks if speed < 0.5 m/s. After 3 consecutive stuck frames within forcedArrivalDist → force arrival |
| 3. Off-Road Walk | TaskGoToCoordAnyMeans with no-vehicle flag lets the paramedic cross grass, sand, or any terrain on foot |
Revive Behavior
Three distinct revive paths, by design — because a doctor finishing treatment should behave differently from an admin force-revive:
| Scenario | Event | Doctor Behavior |
|---|---|---|
| Doctor treatment completes | rde_death:doctorRevive | Walks back to ambulance, drives away, despawns after despawnDelay |
| Admin /revive [id] | rde_death:adminRevive | Immediate ambulance/ped cleanup |
| Hospital respawn | rde_death:doRespawn | Immediate cleanup, fade to hospital |
After every revive path, TriggerEvent('rde_death:localRevive') fires — external scripts like rde_aipd listen on this for instant isDead sync.
Exports
| Export | Returns |
|---|---|
| IsDead(source) | boolean |
| GetDeathState(source) | { isDead, bloodLoss, injuryType, coords, timestamp } |
| RevivePlayer(source) | boolean (admin-context, instant cleanup) |
| GetStats() | { totalDeaths, totalRevives, totalDoctorCalls, totalRevenue, ... } |
Common Pitfalls
isDead stays true in the DB after a doctor heals you
An early version wrote isDead=0 directly via MySQL.update — but ox_core keeps its own in-memory character state, and its next player.save() silently overwrote the direct write with the old stale value.
Fix (v1.0.6): DB_SetIsDead now calls player.set('isDead', false) first, updating ox_core's in-memory state so its own save commits the correct value. The direct MySQL write follows as belt-and-suspenders.
Player stuck dead after server restart
If the server crashed while a player was dead, isDead=1 persisted through the next login.
Fix: onResourceStop now resets isDead=0 in DB for all currently-dead players, and isDead=1 on login triggers an auto-clear + hospital respawn.
Ambulance never arrives off-road
Standard road-only pathfinding means the ambulance loops forever near a park, beach, or field.
Fix: the Grass Fix stuck-detection loop forces the paramedic out on foot — see the dedicated section above.
FAQ
Does this replace ox_core's built-in death system entirely?
Yes — that's why setr ox:deathSystem false is required in server.cfg.
Is the ambulance treatment ever allowed to fail?
Not yet — successRate = 95 exists in config but isn't wired to a failure path yet. Treatment currently always succeeds; this is marked as a known limitation.
Does it integrate with rde_aipd?
Yes — every revive path fires rde_death:localRevive, which rde_aipd listens to for instant isDead sync.
Changelog
isDead sync root cause fix — DB_SetIsDead now updates ox_core's in-memory state via player.set() before the direct MySQL write.
Separate doctorRevive/adminRevive events, Grass Fix stuck-detection loop, onResourceStop DB cleanup for stuck-dead players.