[PAID][QBCore/ESX] Waypoint AI EMS


Preview Trailer Video
Preview Demo Video
Purchase on Tebex

Waypoint AI EMS is a script that enables you to dispatch an AI controlled ambulance to a downed person, it will bring them to the closest hospital and check them in. This script can be used in a variety of ways to enhance your RP.

You can use it to help fill the gap, when your active EMS numbers are low. Or your EMS/Doctors can use it to send the AI out to bring people to the hospital while they focus on building RP out of a hospital.

How it works:

  • When the AI EMS are dispatched, they will spawn within a radius of the downed player and drive to their location
  • The EMS will perform CPR, load the downed person into the ambulance and then drive to the closest hospital
  • Once at the hospital drop off zone, the EMS will unload the person and carry them to the checkin location, where they will be revived
  • Multiple hospital drop off zones can be configured.
  • OneSync compatible
  • Multiple layers of redundancy have been implemented to assist the AI in attempting to get unstuck, should it find itself in such a situation.
  • Support for both QB and ESX, all framework functions are open source in the framework.lua file.
    • You can easily modify the script to support other frameworks by modifying the framework.lua file

Example uses cases:

  • Dispatch AI EMS when player presses a button when they are dead
  • Dispatch AI EMS automatically when player dies
  • Add a command for EMS/Police job to send an AI EMS to the target id
  • In your dispatch app, add a button that lets you send an AI EMS to the downed player via the downed player alerts.

Performance:

  • The script has an idle CPU time of 0.00ms
  • While in use, the CPU time is 0.01ms - 0.02ms

Notes:

  • If AI EMS are called and then the player is moved away from the location and/or revived, then the AI will drive away and despawn
  • AI will drive slower when offroad. This helps ensure they don’t lose control as often.
  • If the player is loaded into the ambulance and it gets stuck for 1.5 minutes(configurable), then the player will be force checked in to the hospital.
  • If the ambulance is not able to get close enough to the person, it may appear that they are stuck. As long as they are within 50 units of the player, they should proceed after waiting for 15 seconds.
  • The script contains an option to run telemetry to measure the success rate of AI EMS in your server.

DISCLAIMERS:

  • For full transparency, this script is NOT going to work 100% of the time.
  • AI navigation is far from perfect. There is no guarantee that the AI EMS will be able to reach the downed players location. There are plenty of variables and obstacles that can result in the AI not reaching a player including but not limited to: downed player location, traffic, other players, etc.
  • The AI EMS tends to have the most difficulties / fail, when the downed person is far away from the road, in tight alleyways, on roof tops, or other hard to reach areas. The success rate, is highly dependent on the location that the AI EMS is dispatched to. It is most successful when the downed person is in an open, accessible area near a road.
  • Custom MLOs are a known problematic area . Often this is due to MLOs not properly setting up a navmesh, which is required for the AI to properly pathfind its way in the world. This often results in the AI EMS not being able to enter or navigate interiors of these MLOS. This is not something that this script can solve.
    • If you have an interior with improper navmesh, it is recommended to have players bring the downed player outside of the building first and then trigger the dispatch AI EMS.
  • The current success rate is approximately 90% (+/- 5% deviation).
    • We have been running this script in a live server for 5+ months, collected telemetry to get an idea of how successful the script is and continually improving reliability by accounting for and fixing edge case scenarios.
    • Here are the numbers we have collected to determine our success rate:
      • started = 1221
      • success = 891
      • success-forced-checkin = 4
      • success-forced-stuck = 66
      • timedout = 73
      • abandoned = 123
      • abandonded-dead = 63
    • Plugging these into the following calculation we get the scenario success rate:
      • Success Rate = (started - abandoned - abandoned-dead) / (success + success-forced-stuck + success-forced-checkin)
      • (1221 - 123- 63) / (891+ 66 + 4) = 92.85%

Documentation and Setup Instructions provided here

Code is accessible Config, Framework, Server
Subscription-based No
Lines (approximately) ~700
Requirements qb-core or esx, qb-ambulancejob (or equivalent), LegacyFuel (or equivalent script)
Support Yes

Checkout my scripts

5 Likes

If the AI can’t reach the player, does he get force send to the hospital after lets say a minute? That would be nice.

Thanks for the suggestion, not a bad idea.

Currently it is setup that the AI EMS must first reach the player and load them into the ambulance, from then, if it gets stuck and EMS is still alive and Config.EnableStuckForceCheckIn == true then it will teleport to the hospital.

I had initially designed it this way in case players intentionally killed or blocked the AI EMS from even reaching the downed player. However, it is a valid scenario and could be one that people want to enable. I’ll add in support for this and put it behind a config toggle.

1 Like

Just wanted to provide an update that I’ve just pushed a new version containing the above mentioned fixes.

Added a new Config variable to give users more control over the stuck force checkin behavior.
You can now choose to have the force checkin logic apply only if the player is already being transported or it can occur even if the ambulance never reaches the player but becomes stuck.

@MafryxZz thanks again for the suggestion!

1 Like

Thank you all for the support and feedback! I’m happy to announce that :ambulance: Waypoint AI EMS now also supports ESX and OX Notify.

I’ve released v1.0.2 which adds framework support.

An open source framework.lua file has been added that contains all framework specific logic. This script now supports QBCore and ESX Frameworks, as well as QBCore, ESX or OX for notifications. Any other framework could also be supported by modifying the frameworks file to support whatever framework or additional scripts you use.

:ambulance: Waypoint AI EMS - v1.0.5

Added additional config options to check for different stuck conditions to bypass and continue to next steps.

  • Config.EnableForceCheckinOnScenarioTimeout: If the scenario timeout (Config.ScenarioTimeOut) is reached and the player has not been checked into the hospital, this will force check in the player to the hospital.
  • Config.EnableStuckCheckTeleportToEmsEscort: This flag is used to enable a check if the EMS gets stuck attempting to reach the player’s downed location (useful for unreachable areas like rooftops). If set to true and the conditions are met, it will allow the player to be teleported to the EMS and continue the remaining scenario steps.
  • Config.StuckCheckTeleportToEmsTimeout: If Config.EnableStuckCheckTeleportToEmsEscort is true, this is the number of seconds the EMS ped must be stuck for to be considered stuck.

:ambulance: Waypoint AI EMS - v1.0.6

Made some tweaks for better integration support with Wasabi Ambulance and other scripts.

- Tweaked `Config.HospitalLocations` to accept `number` or `string` as the `key` type
   - The key value should match the value used in your ambulance script.
   -  By default we use number as the key, which matches the format of qb-ambulancejob. 
   - In Wasabi ambulance a string value is used.
- Added a new config value: `Config.AmbulanceScript`
   - This is currently used for the `IsPlayerDeceased` framework function.
   - Default support for `qb`, `esx`, `wasabi`
- Updated documentation with code snippets for integration with Wasabi Ambulance

Updated documentation with code snippets for integration with Wasabi Ambulance