Flake AI EMS

An AI-driven EMS revival system for FiveM. When no ambulance players are online, downed players can request an AI paramedic to arrive, provide CPR, and revive them for a fee. Supports ESX and QBCore with multiple ambulance resource compatibility.

FiveMESX · QBCoreox_libLua 5.4
Purchase Script
flakedev.com

Overview

Flake AI EMS gives players a fallback option when real paramedics are unavailable. After typing /emshelpwhile downed, an AI paramedic spawns in an ambulance, drives to the player's location, performs CPR, and revives them. The service includes a payment menu (cash or card), optional crutch injury system, and restricted zone support.

Features

  • AI-Driven RevivalSpawns a paramedic NPC with an ambulance, drives to the player, performs CPR animation, then revives.
  • Dynamic SpawningSpawns near the player on a valid road, or falls back to the nearest hospital.
  • Payment SystemCash or card payment with configurable costs. Free revival for on-duty EMS/fire.
  • Ambulance Presence CheckAutomatically disables AI EMS when real ambulance players are online.
  • Crutch IntegrationOptionally applies a temporary crutch injury after revival (Wasabi, AK47 ESX/QB).
  • Restricted ZonesBlock AI EMS in hospitals, police stations, prison, military base, and custom areas.
  • Framework Auto-DetectionDetects ESX or QBCore automatically, or can be forced manually.
  • Blip TrackingLive ambulance blip so players can see the AI EMS approaching.

Requirements

DependencyPurposeRequired
ox_libNotifications, progress bars, context menusYes
ESX or QBCoreFramework for jobs, money, metadata, player dataYes
wasabi_crutchOptional crutch system after revivalNo
ak47_crutch / ak47_qb_crutchOptional AK47 crutch systemNo
wasabi_ambulanceCompatible ambulance scriptNo
qb-ambulancejob / ak47_ambulancejobCompatible ambulance scriptNo

Installation

Step 1 — Drop the Resource

Place the flake_aiems folder into your server's resources directory and add the following to your server.cfg:

server.cfg
ensure flake_aiems

Step 2 — Verify Dependencies

Make sure ox_lib and your framework are started before flake_aiems:

server.cfg
ensure ox_lib
ensure es_extended   -- or: ensure qb-core
ensure flake_aiems

Step 3 — Configure

Edit config.lua to set your framework, command, costs, hospital locations, and restricted zones. See the Configuration section below.

Done

Restart your server and type /emshelp while downed to request AI EMS.

File Structure

flake_aiems/
├── client/
│   └── client.lua  -- Client-side logic (escrowed)
├── server/
│   └── server.lua  -- Server-side logic (escrowed)
├── config.lua  -- All editable settings (escrow-ignored)
└── fxmanifest.lua  -- Resource manifest

Configuration

All settings live in config.lua, which is escrow-ignored and safe to edit. Client and server files are escrow-protected.

Command & Costs

config.lua
Config.Command = 'emshelp'
Config.RevivalCost = {
    cash = 5000,   -- Cash price
    card = 7500,   -- Card/bank price
}

AI EMS Settings

SettingDefaultDescription
Config.EMSModel's_m_m_paramedic_01'Ped model for the AI paramedic
Config.AmbulanceModel'ambulance'Vehicle model for the AI ambulance
Config.EMSSpeed35.0Cruise speed (m/s, ~126 km/h)
Config.EMSTimeout300000Request timeout in ms (5 minutes)

Dynamic Spawn

When enabled, the AI ambulance spawns on a valid road near the player instead of at the nearest hospital:

config.lua
Config.DynamicSpawn = {
    enabled     = true,
    minDistance = 150.0, -- Minimum spawn distance (meters)
    maxDistance = 300.0, -- Maximum spawn distance (meters)
    searchRadius = 50.0  -- Radius to search for a valid road
}

Animation & Progress Bar

config.lua
Config.CPRAnimation = {
    dict     = 'mini@cpr@char_a@cpr_str',
    anim     = 'cpr_pumpchest',
    duration = 10000  -- 10 seconds
}

Config.ProgressBarDuration = 10000
Config.ProgressBarLabel    = 'Receiving medical assistance...'

Crutch System

After revival, a temporary crutch/injury can be applied. Supports auto-detection or manual selection:

config.lua
Config.CrutchSystem = {
    enabled  = true,
    duration = 60000,  -- Duration in ms (1 minute)
    system   = 'auto'  -- 'auto', 'wasabi_crutch', 'ak47_crutch', 'ak47_qb_crutch'
}

-- Jobs exempt from crutches
Config.CrutchExemptJobs = {
    'police', 'sheriff', 'bcso', 'sasp', 'state',
    'ambulance', 'ems', 'fire'
}

Free Revival

Players with certain jobs can bypass payment entirely:

config.lua
Config.FreeRevival = {
    enabled = false,
    jobs    = { 'ambulance', 'fire' }
}

Ambulance Online Check

AI EMS is disabled automatically when real ambulance players are online:

config.lua
Config.CheckAmbulanceOnline  = true
Config.MinAmbulanceRequired = 1

-- Jobs counted as ambulance personnel
Config.AmbulanceJobs = {
    'ambulance',
    -- 'ems',
    -- 'medic',
}

Hospital Locations

Fallback spawn points used when dynamic spawning is disabled:

config.lua
Config.HospitalLocations = {
    { x = 298.67,  y = -584.50,  z = 43.26, heading = 70.0  },  -- Pillbox Medical
    { x = -254.88, y = 6331.23,  z = 32.58, heading = 45.0  },  -- Paleto Bay Medical
    { x = 1839.15, y = 3672.99,  z = 34.28, heading = 210.0 },  -- Sandy Shores Medical
    { x = -449.67, y = -340.83,  z = 34.50, heading = 82.0  },  -- Mount Zonah Medical
}

Adding More Hospitals

Add new entries to Config.HospitalLocations with x, y, z, and heading values. Use a tool like vMenu or /coords to get your coordinates.

Restricted Zones

Block AI EMS from responding in specific areas:

config.lua
Config.RestrictedZones = {
    enabled = true,
    zones = {
        {
            name    = "Pillbox Medical Center",
            coords  = vector3(298.67, -584.50, 43.26),
            radius  = 100.0,
            message = "AI EMS is not available inside medical facilities."
        },
        {
            name    = "Prison",
            coords  = vector3(1845.0, 2585.0, 45.0),
            radius  = 200.0,
            message = "AI EMS is not available in restricted government areas."
        }
    }
}

Notifications

All display text is customizable:

config.lua
Config.Notifications = {
    noMoney          = 'You do not have enough money for medical assistance!',
    emsOnWay         = 'AI EMS is on the way to your location!',
    emsArrived       = 'AI EMS has arrived. Choose your payment method.',
    revived          = 'You have been revived by AI EMS!',
    alreadyRequested = 'You have already requested AI EMS assistance!',
    notDead          = 'You are not in need of medical assistance!',
    paymentSuccess   = 'Payment successful! Receiving medical treatment...',
    crutchApplied    = 'You are injured and need to use crutches for recovery.',
    restrictedZone   = 'AI EMS is not available in this area.',
    freeRevival      = 'AI EMS is providing on-duty medical assistance at no charge.',
}

Debug Mode

config.lua
Config.Debug = false  -- Enable console prints for troubleshooting

Framework Compatibility

Flake AI EMS supports multiple frameworks and ambulance resources out of the box.

Framework Detection

Set Config.Framework to control how the resource initializes:

config.lua
Config.Framework = 'auto'   -- 'esx', 'qb', or 'auto'

In auto mode, the script checks if es_extended or qb-core is started and initializes accordingly.

Supported Ambulance Resources

ResourceFrameworkDead CheckRevive Event
wasabi_ambulanceESX / QBYesYes
qb-ambulancejobQBCoreYesYes
ak47_ambulancejobESXYesYes
ak47_qb_ambulancejobQBCoreYesYes
esx_ambulancejobESXNoYes

Supported Crutch Resources

ResourceFrameworkSystem Name
wasabi_crutchESX / QB'wasabi_crutch'
ak47_crutchESX'ak47_crutch'
ak47_qb_crutchQBCore'ak47_qb_crutch'

Crutch Auto-Detect

When Config.CrutchSystem.system = 'auto', the script tries Wasabi first, then AK47 ESX, then AK47 QB. If none are found, no crutch is applied and a debug message is printed (if debug mode is enabled).

Troubleshooting

IssueFix
Nothing happens when typing /emshelpEnsure ox_lib is started before flake_aiems. Check your framework is running and the command is not already registered by another resource.
AI ambulance never arrivesEnable Config.Debug = true and check the F8 console for spawn or pathfinding errors. Try disabling DynamicSpawn to use hospital spawns instead.
Player is not revived after CPRVerify your ambulance resource is compatible. Check if the resource name matches one of the supported names in the Framework Compatibility table.
Payment fails but money is takenEnsure your framework money functions are working correctly. Check the server console for callback errors.
Crutch is not applied after revivalVerify the crutch resource is started and the system name in Config.CrutchSystem.system matches. Try 'auto' if unsure.
AI EMS responds inside hospitalsAdd hospital coordinates to Config.RestrictedZones with an appropriate radius.
Ambulance players online but AI EMS still worksCheck Config.AmbulanceJobs matches the exact job names your server uses. Enable debug to see the counted players.
Free revival not working for EMSEnable Config.FreeRevival.enabled = true and ensure the job name is in Config.FreeRevival.jobs.

Developed by Flake Development. For support, open a ticket in our Discord.