Waypoint Scripts
  • Waypoint Scripts
  • Store
  • Support Discord
  • Scripts
    • 🚑Waypoint AI EMS
      • 📝Setup
      • 🖥️Code Snippets
      • ❔FAQ
      • 📃Exports / Events
      • 🔢Telemetry
    • 🚕Waypoint AI Taxi
      • 📝Setup
      • 🖥️Code Snippets
      • 📃Exports / Events
      • 🔢Telemetry
    • 🎆Waypoint Fireworks
      • 📝Setup
    • 💡Waypoint Neons
      • 📝Setup
    • 🐕Waypoint Animals
      • 📝Setup
      • ❔FAQ
  • Free Scripts
    • 🚚Waypoint Tow / Hauling
    • 🛠️Waypoint Placeables
    • 🚦Waypoint Traffic Lights
    • 🧘‍♂️Waypoint Yogamats
    • 🖨️Waypoint Printer
    • 🚲Waypoint Pocket Bikes
    • 👻Waypoint Smoke Monster
    • 🪑Waypoint Seats
Powered by GitBook
On this page
  • Configuration
  • Framework Implementations
  • Setup Hospital Locations
  • Dispatch AI EMS
  • Command
  • Client Event
  • Server Event
  • Additional Notes
  1. Scripts
  2. Waypoint AI EMS

Setup

AI EMS Setup Instructions

Configuration

Add the script to your server config

Open the config.luafile and make any necessary adjustments.

Make sure to update the framework / script configuration section with the relevant scripts that you use.

If you select any OX script (or script that uses ox), be sure to uncomment the @ox_lib/init.lua line in the fxmanifest.

Framework Implementations

External script implementations are handled in the framework.lua file. This file provides the necessary functions and hooks to integrate with different frameworks and scripts.

Out of the box, the script includes implementations for:

qb
qbx
esx
ox
wasabi

Framework

Notify

Ambulance / Hospital

LegacyFuel
ox_fuel
ps-fuel

Fuel

If you are using a different framework or script, you will need to add the relevant implementations in the framework.lua file.

If you are using QBCore + qb-ambulancejob, be sure to implement the custom checkin function

Setup Hospital Locations

Configure the HospitalLocations to align with the hospital locations you are using.

These are defined in the Config under GenerateHospitalLocations.

Ensure that key matches the keys used in your ambulance/hospital script.

Dispatch AI EMS

Setup the various ways you want the AI EMS to be dispatched to the downed player.

Example Usage

  • 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.

  • In some cases you may want the EMS dispatched immediately, like when a EMS/police player triggers it to go to a downed person, on the other hand you may want to make it delayed when the person presses a button while dead.

Command

/callems

Enable/Disable command with: Config.EnableCallEMSCommand

Configure whether the command will dispatch immediately or with a delay with Config.IsEMSCommandInstantDispatch.

Rename the command in the server.luafile.

Client Event

-- Called on the client where the AI EMS should be dispatched to
--- @param isInstantDispatch: boolean if true dispatch immediately, else delay based on Config.DispatchEMSWaitTime
TriggerClientEvent('wp-ai-ems:client:DispatchAIEMS', isInstantDispatch)

Server Event

-- Server event to dispatch AI EMS, can be used to dispatch to other players.
--- @param targetId - the serverId of the downed player that the AI EMS is dispatched to
--     Example of how to get the current users serverId: GetPlayerServerId(PlayerId())
--- @param isInstantDispatch: boolean boolean if true dispatch immediately, else delay based on Config.DispatchEMSWaitTime
TriggerServerEvent('wp-ai-ems:server:DispatchAIEMS', targetId, isInstantDispatch)

Example Implementation: Dispatch AI EMS when player presses G while downed

This requires modifying the qb-ambulancejob script. Add the following event to the qb-ambulancejob/server/main.lua :

RegisterNetEvent('hospital:server:RequestEMS', function()
    local src = source
    if doctorCount == 0 then
        local isInstantDispatch = false
        TriggerClientEvent('wp-ai-ems:client:DispatchAIEMS', src, isInstantDispatch)
    end
end)

if IsControlJustPressed(0, 47) and not emsNotified then
    TriggerServerEvent('hospital:server:ambulanceAlert', Lang:t('info.civ_down'))
    emsNotified = true
    TriggerServerEvent("hospital:server:RequestEMS")
end

Note I've configured it to only dispatch if there are no active EMS players. Remove the doctorCount check if you want it to always dispatch.

Additional Notes

  • It is not 100% guaranteed that the AI EMS will be able to reach the downed players location. There are several factors that contribute to reducing the reliability.

  • AI navigation is far from perfect. 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.

PreviousWaypoint AI EMSNextCode Snippets

Last updated 2 months ago

In qb-ambulancejob/client/dead.lua - look for and modify the following code:

Support Discord:

🚑
📝
if IsControlJustPressed(0, 47)
https://discord.gg/3B6bznh4mV