RDE_AIMD DOCS
RED DRAGON ELITE // AI SYSTEMS

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.

01 / Start Here

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.

Core Principle GTA's vehicle pathfinder is road-only. If a player dies off-road, a naive ambulance script will circle the nearest road forever. rde_aimd detects this and forces the paramedic to walk the rest of the way on foot.

Why this over paid/legacy death systems

Paid / Legacy Systemsrde_aimd
ESX/QB only or Tebex lockedPure ox_core, zero legacy dependencies
Ambulance circles roads foreverGrass Fix forces off-road arrival
Instant despawn after reviveDoctor walks back, drives away naturally
No DB persistenceisDead bulletproof DB sync — survives restarts
02 / Start Here

Quick Start

server.cfg
-- 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
Critical 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.

03 / Reference

Configuration

config.lua — Death System
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.lua — AI Ambulance
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
}
04 / Reference

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:

LayerWhat it does
1. Road-Node TargetAmbulance drives toward the nearest road node adjacent to the player via GetClosestVehicleNode(), not the player's exact coords
2. Stuck-DetectionEvery 800ms, checks if speed < 0.5 m/s. After 3 consecutive stuck frames within forcedArrivalDist → force arrival
3. Off-Road WalkTaskGoToCoordAnyMeans with no-vehicle flag lets the paramedic cross grass, sand, or any terrain on foot
05 / Reference

Revive Behavior

Three distinct revive paths, by design — because a doctor finishing treatment should behave differently from an admin force-revive:

ScenarioEventDoctor Behavior
Doctor treatment completesrde_death:doctorReviveWalks back to ambulance, drives away, despawns after despawnDelay
Admin /revive [id]rde_death:adminReviveImmediate ambulance/ped cleanup
Hospital respawnrde_death:doRespawnImmediate 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.

06 / Reference

Exports

ExportReturns
IsDead(source)boolean
GetDeathState(source){ isDead, bloodLoss, injuryType, coords, timestamp }
RevivePlayer(source)boolean (admin-context, instant cleanup)
GetStats(){ totalDeaths, totalRevives, totalDoctorCalls, totalRevenue, ... }
07 / More

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.

08 / More

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.

09 / More

Changelog

v1.0.6

isDead sync root cause fix — DB_SetIsDead now updates ox_core's in-memory state via player.set() before the direct MySQL write.

v1.0.5

Separate doctorRevive/adminRevive events, Grass Fix stuck-detection loop, onResourceStop DB cleanup for stuck-dead players.