├── hh_aidoc[ESX] ├── config.lua ├── fxmanifest.lua ├── server.lua └── client.lua ├── hh_aidoc[QB] ├── config.lua ├── fxmanifest.lua ├── server.lua └── client.lua └── README.md /hh_aidoc[ESX]/config.lua: -------------------------------------------------------------------------------- 1 | ------------------- 2 | -- CONFIG -- 3 | ------------------- 4 | Config = {} 5 | 6 | Config.Doctor = 0 -- Minimum Amount of EMS to work 7 | Config.Price = 2000 8 | Config.ReviveTime = 20000 --in msec 9 | 10 | -------------------------------------------------------------------------------- /hh_aidoc[QB]/config.lua: -------------------------------------------------------------------------------- 1 | ------------------- 2 | -- CONFIG -- 3 | ------------------- 4 | Config = {} 5 | 6 | Config.Doctor = 0 -- Minimum Amount of EMS to work 7 | Config.Price = 2000 8 | Config.ReviveTime = 20000 --in msec 9 | 10 | -------------------------------------------------------------------------------- /hh_aidoc[ESX]/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | 3 | game 'gta5' 4 | 5 | description 'HHFW AI Doc' 6 | 7 | version '0.1.0' 8 | 9 | 10 | client_scripts { 11 | 'config.lua', 12 | 'client.lua' 13 | } 14 | 15 | server_scripts { 16 | 'config.lua', 17 | 'server.lua' 18 | } 19 | -------------------------------------------------------------------------------- /hh_aidoc[QB]/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | 3 | game 'gta5' 4 | 5 | description 'HHFW AI Doc [QB]' 6 | 7 | version '0.1.0' 8 | 9 | 10 | client_scripts { 11 | 'client.lua' 12 | } 13 | 14 | server_scripts { 15 | 'server.lua' 16 | } 17 | 18 | shared_scripts { 19 | 'config.lua' 20 | } 21 | -------------------------------------------------------------------------------- /hh_aidoc[ESX]/server.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 3 | 4 | ESX.RegisterServerCallback('hhfw:docOnline' , function(source, cb) 5 | local src = source 6 | local Ply = ESX.GetPlayerFromId(src) 7 | local xPlayers = ESX.GetPlayers() 8 | local doctor = 0 9 | local canpay = false 10 | if Ply.getMoney() >= Config.Price then 11 | canpay = true 12 | else 13 | if Ply.getAccount('bank').money >= Config.Price then 14 | canpay = true 15 | end 16 | end 17 | 18 | for i=1, #xPlayers, 1 do 19 | local xPlayer = ESX.GetPlayerFromId(xPlayers[i]) 20 | if xPlayer.job.name == 'ambulance' then 21 | doctor = doctor + 1 22 | end 23 | end 24 | 25 | cb(doctor, canpay) 26 | end) 27 | 28 | 29 | 30 | RegisterServerEvent('hhfw:charge') 31 | AddEventHandler('hhfw:charge', function() 32 | local src = source 33 | local xPlayer = ESX.GetPlayerFromId(src) 34 | if xPlayer.getMoney()>= Config.Price then 35 | xPlayer.removeMoney(Config.Price) 36 | else 37 | xPlayer.removeAccountMoney('bank', Config.Price) 38 | end 39 | end) 40 | -------------------------------------------------------------------------------- /hh_aidoc[QB]/server.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | QBCore.Functions.CreateCallback('hhfw:docOnline', function(source, cb) 4 | local src = source 5 | local Ply = QBCore.Functions.GetPlayer(src) 6 | local xPlayers = QBCore.Functions.GetPlayers() 7 | local doctor = 0 8 | local canpay = false 9 | if Ply.PlayerData.money["cash"] >= Config.Price then 10 | canpay = true 11 | else 12 | if Ply.PlayerData.money["bank"] >= Config.Price then 13 | canpay = true 14 | end 15 | end 16 | 17 | for i=1, #xPlayers, 1 do 18 | local xPlayer = QBCore.Functions.GetPlayer(xPlayers[i]) 19 | if xPlayer.PlayerData.job.name == 'ambulance' then 20 | doctor = doctor + 1 21 | end 22 | end 23 | 24 | cb(doctor, canpay) 25 | end) 26 | 27 | 28 | 29 | RegisterServerEvent('hhfw:charge') 30 | AddEventHandler('hhfw:charge', function() 31 | local src = source 32 | local xPlayer = QBCore.Functions.GetPlayer(src) 33 | if xPlayer.PlayerData.money["cash"] >= Config.Price then 34 | xPlayer.Functions.RemoveMoney("cash", Config.Price) 35 | else 36 | xPlayer.Functions.RemoveMoney("bank", Config.Price) 37 | end 38 | TriggerEvent("qb-bossmenu:server:addAccountMoney", 'ambulance', Config.Price) 39 | end) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hh_aidoc 2 | AI Doctor 3 | 4 | # Description : 5 | 6 | This script is basically for to be used in the server when there are no ems /doctors available in the server the players will get an option to pay and get helped/revived on there spot present by a moving ambulance with a doctor! 7 | 8 | # Features : 9 | 10 | - This script is a very useful for huge servers where the population have no option rather than respawning 11 | every time they will get to experience more rp by this method! 12 | - The ems ped in the ambulance can come from anywhere it doesn't matter where you are located and it 13 | will be in a well mannered way 14 | - Money/fees of the ambulance and the ems ped will be deducted for there service! 15 | - The driving manner of the ped is very well organized it wont drive recklessly! 16 | - This script is highly configurable according to your choice all of the options you see in the video and 17 | features are editable with the notifications! 18 | - This script is basically for enhancing and bringing up more rp in the server rather than respawning! 19 | - This script supports ESX and QB and if any excessive support needed hit me up! 20 | - It will automatically adapt to your framework whether ESX/QB basically its a put and run script! 21 | - This script is uploaded on GitHub so you guys can request pull requests so feel free to add some required and 22 | useful changes. 23 | - Feel free to do whatever you like with this script just don't edit and resell lol! 24 | 25 | Forum : https://forum.cfx.re/t/qb-esx-hh-aid-doctor-ai-doctor-release-free/4768466 26 | 27 | Preview : https://www.youtube.com/watch?v=HdY6m8EZGDQ 28 | 29 | -------------------------------------------------------------------------------- /hh_aidoc[QB]/client.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | local Active = false 4 | local test = nil 5 | local test1 = nil 6 | local spam = true 7 | 8 | 9 | 10 | 11 | RegisterCommand("help", function(source, args, raw) 12 | if (QBCore.Functions.GetPlayerData().metadata["isdead"]) or (QBCore.Functions.GetPlayerData().metadata["inlaststand"]) and spam then 13 | QBCore.Functions.TriggerCallback('hhfw:docOnline', function(EMSOnline, hasEnoughMoney) 14 | if EMSOnline <= Config.Doctor and hasEnoughMoney and spam then 15 | SpawnVehicle(GetEntityCoords(PlayerPedId())) 16 | TriggerServerEvent('hhfw:charge') 17 | Notify("Medic is arriving") 18 | else 19 | if EMSOnline > Config.Doctor then 20 | Notify("There is too many medics online", "error") 21 | elseif not hasEnoughMoney then 22 | Notify("Not Enough Money", "error") 23 | else 24 | Notify("Wait Paramadic is on its Way", "primary") 25 | end 26 | end 27 | end) 28 | else 29 | Notify("This can only be used when dead", "error") 30 | end 31 | end) 32 | 33 | 34 | 35 | function SpawnVehicle(x, y, z) 36 | spam = false 37 | local vehhash = GetHashKey("ambulance") 38 | local loc = GetEntityCoords(PlayerPedId()) 39 | RequestModel(vehhash) 40 | while not HasModelLoaded(vehhash) do 41 | Wait(1) 42 | end 43 | RequestModel('s_m_m_doctor_01') 44 | while not HasModelLoaded('s_m_m_doctor_01') do 45 | Wait(1) 46 | end 47 | local spawnRadius = 40 48 | local found, spawnPos, spawnHeading = GetClosestVehicleNodeWithHeading(loc.x + math.random(-spawnRadius, spawnRadius), loc.y + math.random(-spawnRadius, spawnRadius), loc.z, 0, 3, 0) 49 | 50 | if not DoesEntityExist(vehhash) then 51 | mechVeh = CreateVehicle(vehhash, spawnPos, spawnHeading, true, false) 52 | ClearAreaOfVehicles(GetEntityCoords(mechVeh), 5000, false, false, false, false, false); 53 | SetVehicleOnGroundProperly(mechVeh) 54 | SetVehicleNumberPlateText(mechVeh, "HHFW") 55 | SetEntityAsMissionEntity(mechVeh, true, true) 56 | SetVehicleEngineOn(mechVeh, true, true, false) 57 | 58 | mechPed = CreatePedInsideVehicle(mechVeh, 26, GetHashKey('s_m_m_doctor_01'), -1, true, false) 59 | 60 | mechBlip = AddBlipForEntity(mechVeh) 61 | SetBlipFlashes(mechBlip, true) 62 | SetBlipColour(mechBlip, 5) 63 | 64 | 65 | PlaySoundFrontend(-1, "Text_Arrive_Tone", "Phone_SoundSet_Default", 1) 66 | Wait(2000) 67 | TaskVehicleDriveToCoord(mechPed, mechVeh, loc.x, loc.y, loc.z, 20.0, 0, GetEntityModel(mechVeh), 524863, 2.0) 68 | test = mechVeh 69 | test1 = mechPed 70 | Active = true 71 | end 72 | end 73 | 74 | Citizen.CreateThread(function() 75 | while true do 76 | Citizen.Wait(200) 77 | if Active then 78 | local loc = GetEntityCoords(GetPlayerPed(-1)) 79 | local lc = GetEntityCoords(test) 80 | local ld = GetEntityCoords(test1) 81 | local dist = Vdist(loc.x, loc.y, loc.z, lc.x, lc.y, lc.z) 82 | local dist1 = Vdist(loc.x, loc.y, loc.z, ld.x, ld.y, ld.z) 83 | if dist <= 10 then 84 | if Active then 85 | TaskGoToCoordAnyMeans(test1, loc.x, loc.y, loc.z, 1.0, 0, 0, 786603, 0xbf800000) 86 | end 87 | if dist1 <= 1 then 88 | Active = false 89 | ClearPedTasksImmediately(test1) 90 | DoctorNPC() 91 | end 92 | end 93 | end 94 | end 95 | end) 96 | 97 | 98 | function DoctorNPC() 99 | RequestAnimDict("mini@cpr@char_a@cpr_str") 100 | while not HasAnimDictLoaded("mini@cpr@char_a@cpr_str") do 101 | Citizen.Wait(1000) 102 | end 103 | 104 | TaskPlayAnim(test1, "mini@cpr@char_a@cpr_str","cpr_pumpchest",1.0, 1.0, -1, 9, 1.0, 0, 0, 0) 105 | QBCore.Functions.Progressbar("revive_doc", "The doctor is giving you medical aid", Config.ReviveTime, false, false, { 106 | disableMovement = false, 107 | disableCarMovement = false, 108 | disableMouse = false, 109 | disableCombat = true, 110 | }, {}, {}, {}, function() -- Done 111 | ClearPedTasks(test1) 112 | Citizen.Wait(500) 113 | TriggerEvent("hospital:client:Revive") 114 | StopScreenEffect('DeathFailOut') 115 | Notify("Your treatment is done, you were charged: "..Config.Price, "success") 116 | RemovePedElegantly(test1) 117 | DeleteEntity(test) 118 | Wait(5000) 119 | DeleteEntity(test1) 120 | spam = true 121 | end) 122 | end 123 | 124 | 125 | function Notify(msg, state) 126 | QBCore.Functions.Notify(msg, state) 127 | end 128 | -------------------------------------------------------------------------------- /hh_aidoc[ESX]/client.lua: -------------------------------------------------------------------------------- 1 | local ESX = nil 2 | 3 | Citizen.CreateThread(function() 4 | while ESX == nil do 5 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 6 | Citizen.Wait(200) 7 | end 8 | end) 9 | 10 | local Active = false 11 | local test = nil 12 | local test1 = nil 13 | local spam = true 14 | 15 | local isDead = false 16 | 17 | 18 | AddEventHandler('playerSpawned', function(spawn) 19 | isDead = false 20 | end) 21 | 22 | AddEventHandler('esx:onPlayerDeath', function(data) 23 | isDead = true 24 | end) 25 | 26 | 27 | 28 | RegisterCommand("help", function(source, args, raw) 29 | if isDead and spam then 30 | ESX.TriggerServerCallback('hhfw:docOnline', function(EMSOnline, hasEnoughMoney) 31 | 32 | if EMSOnline <= Config.Doctor and hasEnoughMoney and spam then 33 | SpawnVehicle(GetEntityCoords(PlayerPedId())) 34 | TriggerServerEvent('hhfw:charge') 35 | Notify("Medic is arriving") 36 | else 37 | if EMSOnline > Config.Doctor then 38 | Notify("There is too many medics online", "error") 39 | elseif not hasEnoughMoney then 40 | Notify("Not Enough Money") 41 | else 42 | Notify("Wait Paramadic is on its Way") 43 | end 44 | end 45 | end) 46 | else 47 | Notify("This can only be used when dead") 48 | end 49 | end) 50 | 51 | 52 | 53 | function SpawnVehicle(x, y, z) 54 | spam = false 55 | local vehhash = GetHashKey("ambulance") 56 | local loc = GetEntityCoords(PlayerPedId()) 57 | RequestModel(vehhash) 58 | while not HasModelLoaded(vehhash) do 59 | Wait(1) 60 | end 61 | RequestModel('s_m_m_doctor_01') 62 | while not HasModelLoaded('s_m_m_doctor_01') do 63 | Wait(1) 64 | end 65 | local spawnRadius = 40 66 | local found, spawnPos, spawnHeading = GetClosestVehicleNodeWithHeading(loc.x + math.random(-spawnRadius, spawnRadius), loc.y + math.random(-spawnRadius, spawnRadius), loc.z, 0, 3, 0) 67 | 68 | if not DoesEntityExist(vehhash) then 69 | mechVeh = CreateVehicle(vehhash, spawnPos, spawnHeading, true, false) 70 | ClearAreaOfVehicles(GetEntityCoords(mechVeh), 5000, false, false, false, false, false); 71 | SetVehicleOnGroundProperly(mechVeh) 72 | SetVehicleNumberPlateText(mechVeh, "HHFW") 73 | SetEntityAsMissionEntity(mechVeh, true, true) 74 | SetVehicleEngineOn(mechVeh, true, true, false) 75 | 76 | mechPed = CreatePedInsideVehicle(mechVeh, 26, GetHashKey('s_m_m_doctor_01'), -1, true, false) 77 | 78 | mechBlip = AddBlipForEntity(mechVeh) 79 | SetBlipFlashes(mechBlip, true) 80 | SetBlipColour(mechBlip, 5) 81 | 82 | 83 | PlaySoundFrontend(-1, "Text_Arrive_Tone", "Phone_SoundSet_Default", 1) 84 | Wait(2000) 85 | TaskVehicleDriveToCoord(mechPed, mechVeh, loc.x, loc.y, loc.z, 20.0, 0, GetEntityModel(mechVeh), 524863, 2.0) 86 | test = mechVeh 87 | test1 = mechPed 88 | Active = true 89 | end 90 | end 91 | 92 | Citizen.CreateThread(function() 93 | while true do 94 | Citizen.Wait(200) 95 | if Active then 96 | local loc = GetEntityCoords(GetPlayerPed(-1)) 97 | local lc = GetEntityCoords(test) 98 | local ld = GetEntityCoords(test1) 99 | local dist = Vdist(loc.x, loc.y, loc.z, lc.x, lc.y, lc.z) 100 | local dist1 = Vdist(loc.x, loc.y, loc.z, ld.x, ld.y, ld.z) 101 | if dist <= 10 then 102 | if Active then 103 | TaskGoToCoordAnyMeans(test1, loc.x, loc.y, loc.z, 1.0, 0, 0, 786603, 0xbf800000) 104 | end 105 | if dist1 <= 1 then 106 | Active = false 107 | ClearPedTasksImmediately(test1) 108 | DoctorNPC() 109 | end 110 | end 111 | end 112 | end 113 | end) 114 | 115 | 116 | function DoctorNPC() 117 | RequestAnimDict("mini@cpr@char_a@cpr_str") 118 | while not HasAnimDictLoaded("mini@cpr@char_a@cpr_str") do 119 | Citizen.Wait(1000) 120 | end 121 | 122 | TaskPlayAnim(test1, "mini@cpr@char_a@cpr_str","cpr_pumpchest",1.0, 1.0, -1, 9, 1.0, 0, 0, 0) 123 | --exports['progressBars']:startUI(Config.ReviveTime, "The doctor is giving you medical aid") 124 | TriggerEvent("mythic_progbar:client:progress", { 125 | name = "ai_doc", 126 | duration = Config.ReviveTime, 127 | label = "The doctor is giving you medical aid", 128 | useWhileDead = true, 129 | canCancel = false, 130 | controlDisables = { 131 | disableMovement = true, 132 | disableCarMovement = true, 133 | disableMouse = false, 134 | disableCombat = true, 135 | }, 136 | animation = {}, 137 | prop = {} 138 | }, function(status) 139 | if not status then 140 | ClearPedTasks(test1) 141 | Citizen.Wait(500) 142 | TriggerEvent('esx_ambulancejob:revive') 143 | StopScreenEffect('DeathFailOut') 144 | Notify("Your treatment is done, you were charged: "..Config.Price) 145 | RemovePedElegantly(test1) 146 | DeleteEntity(test) 147 | spam = true 148 | end 149 | end) 150 | end 151 | 152 | 153 | function Notify(msg) 154 | ESX.ShowNotification(msg) 155 | end 156 | --------------------------------------------------------------------------------