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.
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 Revival — Spawns a paramedic NPC with an ambulance, drives to the player, performs CPR animation, then revives.
- •Dynamic Spawning — Spawns near the player on a valid road, or falls back to the nearest hospital.
- •Payment System — Cash or card payment with configurable costs. Free revival for on-duty EMS/fire.
- •Ambulance Presence Check — Automatically disables AI EMS when real ambulance players are online.
- •Crutch Integration — Optionally applies a temporary crutch injury after revival (Wasabi, AK47 ESX/QB).
- •Restricted Zones — Block AI EMS in hospitals, police stations, prison, military base, and custom areas.
- •Framework Auto-Detection — Detects ESX or QBCore automatically, or can be forced manually.
- •Blip Tracking — Live ambulance blip so players can see the AI EMS approaching.
Requirements
| Dependency | Purpose | Required |
|---|---|---|
ox_lib | Notifications, progress bars, context menus | Yes |
| ESX or QBCore | Framework for jobs, money, metadata, player data | Yes |
wasabi_crutch | Optional crutch system after revival | No |
ak47_crutch / ak47_qb_crutch | Optional AK47 crutch system | No |
wasabi_ambulance | Compatible ambulance script | No |
qb-ambulancejob / ak47_ambulancejob | Compatible ambulance script | No |
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:
ensure flake_aiemsStep 2 — Verify Dependencies
Make sure ox_lib and your framework are started before flake_aiems:
ensure ox_lib
ensure es_extended -- or: ensure qb-core
ensure flake_aiemsStep 3 — Configure
Edit config.lua to set your framework, command, costs, hospital locations, and restricted zones. See the Configuration section below.
Done
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.Command = 'emshelp'
Config.RevivalCost = {
cash = 5000, -- Cash price
card = 7500, -- Card/bank price
}AI EMS Settings
| Setting | Default | Description |
|---|---|---|
Config.EMSModel | 's_m_m_paramedic_01' | Ped model for the AI paramedic |
Config.AmbulanceModel | 'ambulance' | Vehicle model for the AI ambulance |
Config.EMSSpeed | 35.0 | Cruise speed (m/s, ~126 km/h) |
Config.EMSTimeout | 300000 | Request 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.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.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.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.FreeRevival = {
enabled = false,
jobs = { 'ambulance', 'fire' }
}Ambulance Online Check
AI EMS is disabled automatically when real ambulance players are online:
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.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
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.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.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.Debug = false -- Enable console prints for troubleshootingFramework 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.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
| Resource | Framework | Dead Check | Revive Event |
|---|---|---|---|
wasabi_ambulance | ESX / QB | Yes | Yes |
qb-ambulancejob | QBCore | Yes | Yes |
ak47_ambulancejob | ESX | Yes | Yes |
ak47_qb_ambulancejob | QBCore | Yes | Yes |
esx_ambulancejob | ESX | No | Yes |
Supported Crutch Resources
| Resource | Framework | System Name |
|---|---|---|
wasabi_crutch | ESX / QB | 'wasabi_crutch' |
ak47_crutch | ESX | 'ak47_crutch' |
ak47_qb_crutch | QBCore | 'ak47_qb_crutch' |
Crutch Auto-Detect
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
| Issue | Fix |
|---|---|
Nothing happens when typing /emshelp | Ensure 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 arrives | Enable 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 CPR | Verify 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 taken | Ensure your framework money functions are working correctly. Check the server console for callback errors. |
| Crutch is not applied after revival | Verify the crutch resource is started and the system name in Config.CrutchSystem.system matches. Try 'auto' if unsure. |
| AI EMS responds inside hospitals | Add hospital coordinates to Config.RestrictedZones with an appropriate radius. |
| Ambulance players online but AI EMS still works | Check Config.AmbulanceJobs matches the exact job names your server uses. Enable debug to see the counted players. |
| Free revival not working for EMS | Enable 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.
