An AI-powered emergency medical service script for FiveM that supports both QBCore and ESX frameworks with optional ox_lib integration for enhanced UI/UX.
- Multi-Framework Support: Automatically detects and works with QBCore or ESX
- ox_lib Integration: Uses ox_lib for notifications and progress bars (with framework fallbacks)
- Smart EMS Detection: Only available when real EMS personnel are unavailable
- Configurable Payment System: Support for cash, bank, or both payment methods
- Cooldown System: Prevents spam and abuse with customizable cooldown timers
- Society Integration: Payments can be sent to ambulance society/job accounts
- Multiple Revive Systems: Supports wasabi_ambulance, QBCore hospital, ESX ambulancejob, and custom systems
- Fully Customizable: Extensive configuration options for every aspect
- Clean Code: Well-organized, documented, and optimized
- FiveM Server (build 5848 or higher)
- OneSync enabled
- One of the following frameworks:
- QBCore Framework
- ESX Legacy (or older versions)
- ox_lib (for better notifications and progress bars)
- wasabi_ambulance (for revive functionality)
- qb-management or qb-bossmenu (for QBCore society accounts)
- esx_society or esx_addonaccount (for ESX society accounts)
- Download or clone this repository
- Place the
donk_aidoctorfolder in your server'sresourcesdirectory - Add
ensure donk_aidoctorto yourserver.cfg - Configure the script by editing
config.lua(see Configuration section) - Restart your server or start the resource with
start donk_aidoctor
Edit config.lua to customize the script. All options are documented with comments.
Config.Framework = 'auto' -- Options: 'auto', 'qbcore', 'esx'auto: Automatically detects your frameworkqbcore: Force QBCore modeesx: Force ESX mode
Config.Command = 'aidoctor' -- Command to call AI doctorPlayers will use /aidoctor to call the AI doctor when dead.
Config.MinEMS = 0 -- Minimum number of online EMS required
Config.EMSJob = 'ambulance' -- Job name for EMS personnel0: AI doctor always available>0: AI doctor only available when EMS count is at or below this number
Config.Price = 2000 -- Price for AI doctor service
Config.PaymentAccount = 'cash' -- Options: 'cash', 'bank', 'both'
Config.SendToSociety = true -- Send payment to society account
Config.SocietyAccount = 'ambulance' -- Society account nameConfig.VehicleModel = 'ambulance' -- Vehicle to spawn
Config.DoctorPed = 's_m_m_doctor_01' -- NPC model
Config.DoctorSpeed = 20.0 -- Driving speed
Config.SpawnDistance = 40.0 -- Distance from player to spawnConfig.ReviveSystem = 'auto' -- Options: 'auto', 'wasabi', 'qbcore', 'esx', 'custom'
Config.CustomReviveEvent = nil -- For custom revive systemsauto: Automatically detects available revive systemwasabi: Uses wasabi_ambulanceqbcore: Uses QBCore hospital systemesx: Uses ESX ambulancejobcustom: Uses custom event (set CustomReviveEvent)
All messages can be customized in the Config.Locale table:
Config.Locale = {
['not_dead'] = 'You are not dead or injured!',
['ems_available'] = 'There are EMS personnel available! Call them first.',
-- ... and more
}- When dead or in last stand, type
/aidoctor(or your configured command) - The system checks:
- Are you actually dead?
- Are there too many EMS online?
- Do you have enough money?
- Are you on cooldown?
- If all checks pass:
- An ambulance spawns nearby
- A doctor NPC drives to your location
- The doctor approaches and performs CPR
- You are revived and charged the configured price
Debug Mode: Enable debug logging by setting Config.Debug = true in config.lua
Cooldown Management: Cooldowns are automatically cleared when players disconnect
- Full support for all QBCore features
- Integrates with qb-management/qb-bossmenu for society accounts
- Supports both cash and bank accounts
- Compatible with QBCore metadata system
- Full support for ESX Legacy and older versions
- Integrates with esx_society/esx_addonaccount for society accounts
- Supports money and bank accounts
- Compatible with ESX job system
- Uses ox_lib notifications when available
- Uses ox_lib progress bars when available
- Falls back to framework-specific UI if ox_lib not present
donk_aidoctor/
├── fxmanifest.lua # Resource manifest
├── config.lua # Configuration file
├── README.md # This file
├── shared/
│ └── framework.lua # Framework abstraction layer
├── client/
│ └── client.lua # Client-side logic
└── server/
└── server.lua # Server-side logic
TriggerServerEvent:
donk_aidoctor:charge- Charges the player for the servicedonk_aidoctor:revivePlayer- Requests player revival
Framework.RegisterCallback:
donk_aidoctor:docOnline- Checks if AI doctor is available- Returns:
canCall, hasEnoughMoney, reason, extraData
- Returns:
To use a custom revive system:
- Set
Config.ReviveSystem = 'custom' - Set
Config.CustomReviveEvent = 'your_custom_event' - Your event will be triggered when revival is needed
Example:
Config.ReviveSystem = 'custom'
Config.CustomReviveEvent = 'myserver:revivePlayer'- Check if you're actually dead
- Verify there aren't too many EMS online (check Config.MinEMS)
- Ensure you have enough money
- Check if you're on cooldown
- Enable debug mode (
Config.Debug = true) to see detailed logs in F8 console
- Check F8 console with debug mode enabled to see distance calculations
- Verify the doctor is exiting the vehicle (look for "Doctor exiting vehicle" in console)
- Increase
Config.TreatmentDistanceif doctor never gets close enough (try 3.0) - Ensure there are no obstacles blocking the doctor's path
- The doctor must be within
Config.ApproachDistanceto exit vehicle and approach
- Ensure your framework is started before this resource
- Check server console for error messages
- Try forcing framework mode in config (set to 'qbcore' or 'esx')
- Verify ox_lib is installed and started
- Check that
@ox_lib/init.luais in shared_scripts (fxmanifest.lua) - The script will automatically fall back to framework UI if ox_lib isn't available
- QBCore: Ensure qb-management or qb-bossmenu is running
- ESX: Ensure esx_society or esx_addonaccount is running
- Check society account name matches your configuration
- FIXED: Removed problematic character loaded check that prevented dead players from calling doctor
- FIXED: Improved doctor exit vehicle and approach logic
- FIXED: Added proper state tracking for doctor exiting vehicle
- IMPROVED: Enhanced proximity detection and treatment distance checks
- IMPROVED: Better debug logging for distance tracking
- CHANGED: Increased default approach distance to 15.0 for more reliable detection
- CHANGED: Treatment distance now properly configurable (default: 1.0)
- Complete rewrite with multi-framework support
- Added ESX framework support
- Integrated ox_lib for better UI/UX
- Added framework abstraction layer
- Expanded configuration options
- Implemented proper cooldown system
- Improved code organization and documentation
- Added debug mode
- Better error handling and cleanup
- Changed default command from
/helpto/aidoctor
- QBCore-only implementation
- Basic AI doctor functionality
- Original Author: donk
- Framework Abstraction & Improvements: donk_aidoctor v2.0
For issues, suggestions, or questions, please open an issue on the GitHub repository.
This project is open source and available under the MIT License.
