├── lb-aidoc ├── fxmanifest.lua ├── config.lua ├── server.lua └── client.lua └── README.md /lb-aidoc/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'adamant' 2 | 3 | game 'gta5' 4 | 5 | authors 'GLDNRMZ#8700 / HHFW / Sanriku / amrclake' 6 | 7 | client_scripts { 8 | 'client.lua' 9 | } 10 | 11 | server_scripts { 12 | 'server.lua' 13 | } 14 | 15 | shared_scripts { 16 | 'config.lua' 17 | } 18 | -------------------------------------------------------------------------------- /lb-aidoc/config.lua: -------------------------------------------------------------------------------- 1 | -------------------- 2 | -- CONFIG -- 3 | -------------------- 4 | Config = {} 5 | 6 | Config.Debug = false 7 | 8 | Config.Doctor = 1 -- Minimum Amount of EMS to work 9 | Config.Price = 1500 -- Cost for AI Doc Services 10 | Config.ReviveTime = 30 -- in seconds 11 | Config.TPTime = 60 -- in seconds 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GLDNRMZ-aidoc 2 | 3 | * Original QBcore versoin by [hhfw1](https://github.com/hhfw1/hh_aidoc) 4 | * Teleport rework by: [Sanriku](https://github.com/Sanriku-Gaming) 5 | * Jail Snippet by: amrclake 6 | 7 | Drop into resources and start. 8 | 9 | # Additions 10 | 11 | * Teleports you to ped after 1 min of calling /help if ambulance is stuck or you're in a weird spot. 12 | * Now teleports you next to the ped if in a vehicle. 13 | * Peds changed from a doctor to paramedic 14 | * Peds now run to and from your location 15 | * Peds now gets back in the vehicle and drives away 16 | * Peds now use ambient speech (driver curses and passenger insults you) 17 | * Vehicle turns on lights and sirens 18 | * Looks for medics on duty rather than online 19 | -------------------------------------------------------------------------------- /lb-aidoc/server.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | QBCore.Functions.CreateCallback('lb: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' and xPlayer.PlayerData.job.onduty then 20 | doctor = doctor + 1 21 | end 22 | end 23 | 24 | cb(doctor, canpay) 25 | end) 26 | 27 | RegisterServerEvent('lb:charge') 28 | AddEventHandler('lb:charge', function() 29 | local src = source 30 | local xPlayer = QBCore.Functions.GetPlayer(src) 31 | if xPlayer.PlayerData.money["cash"] >= Config.Price then 32 | xPlayer.Functions.RemoveMoney("cash", Config.Price, GetCurrentResourceName()..' - AI Doc Fees') 33 | else 34 | xPlayer.Functions.RemoveMoney("bank", Config.Price, GetCurrentResourceName()..' - AI Doc Fees') 35 | end 36 | exports['qb-banking']:AddMoney('ambulance', Config.Price) 37 | end) 38 | -------------------------------------------------------------------------------- /lb-aidoc/client.lua: -------------------------------------------------------------------------------- 1 | local QBCore = exports['qb-core']:GetCoreObject() 2 | 3 | local Active = false 4 | local Revived = false 5 | local calledHelp = false 6 | local veh = nil 7 | local ped1 = nil 8 | local ped2 = nil 9 | local ANIM_DICT = "mini@cpr@char_a@cpr_str" 10 | local REVIVE_TIME = Config.ReviveTime * 1000 11 | local PRICE = Config.Price 12 | 13 | local lastDoctorTime = 0 14 | local sleep = 200 15 | 16 | TriggerEvent('chat:addSuggestion', '/help', 'Call a Local Paramedic') 17 | RegisterCommand("help", function(source, args, raw) 18 | local playerData = QBCore.Functions.GetPlayerData() 19 | 20 | if not playerData.metadata["isdead"] and not playerData.metadata["inlaststand"] then 21 | QBCore.Functions.Notify("This can only be used when dead", "error") 22 | TriggerServerEvent("qb-log:server:CreateLog", "commands", "Help Command Fail", "red", "Player **".. playerData.name .. "** Character Name: **" .. playerData.charinfo["firstname"] .. " " .. playerData.charinfo["lastname"] .. "** attempted to use /help while not dead.") 23 | return 24 | end 25 | 26 | if not playerData.metadata["injail"] then 27 | QBCore.Functions.Notify("This can't be used when in jail", "error") 28 | return 29 | end 30 | 31 | QBCore.Functions.TriggerCallback('lb:docOnline', function(EMSOnline, hasEnoughMoney) 32 | if EMSOnline <= Config.Doctor and hasEnoughMoney then 33 | if not calledHelp then 34 | calledHelp = true 35 | Revived = false 36 | lastDoctorTime = GetGameTimer() 37 | QBCore.Functions.Notify("Paramedic is on its Way", "primary", 60000) 38 | TriggerServerEvent("qb-log:server:CreateLog", "commands", "Help Command Success", "blue", "Player **".. playerData.name .. "** Character Name: **" .. playerData.charinfo["firstname"] .. " " .. playerData.charinfo["lastname"] .. "** used /help! A ambulance is on the way to revive them.") 39 | SpawnVehicle(GetEntityCoords(PlayerPedId())) 40 | else 41 | QBCore.Functions.Notify("You've already called for help, please be patient", "error") 42 | end 43 | elseif EMSOnline > Config.Doctor then 44 | QBCore.Functions.Notify("There are too many medics on duty", "error") 45 | elseif not hasEnoughMoney then 46 | QBCore.Functions.Notify("Not Enough Money", "error") 47 | end 48 | end) 49 | end) 50 | 51 | function SpawnVehicle(x, y, z) 52 | spam = false 53 | local vehhash = GetHashKey("ambulance") 54 | 55 | RequestModel(vehhash) 56 | RequestModel('s_m_m_paramedic_01') 57 | while not HasModelLoaded(vehhash) or not HasModelLoaded('s_m_m_paramedic_01') do 58 | Wait(1) 59 | end 60 | 61 | local spawnRadius = 60 62 | local loc = GetEntityCoords(PlayerPedId()) 63 | local found, spawnPos, spawnHeading = GetClosestVehicleNodeWithHeading(loc.x + math.random(-spawnRadius, spawnRadius), loc.y + math.random(-spawnRadius, spawnRadius), loc.z, 0, 3, 0) 64 | 65 | if DoesEntityExist(vehhash) then 66 | return 67 | end 68 | 69 | local docVeh = CreateVehicle(vehhash, spawnPos, spawnHeading, true, false) 70 | SetVehicleOnGroundProperly(docVeh) 71 | SetVehicleNumberPlateText(docVeh, "QUICKFIX") 72 | SetEntityAsMissionEntity(docVeh, true, true) 73 | SetVehicleEngineOn(docVeh, true, true, false) 74 | SetVehicleSiren(docVeh, true) 75 | 76 | local docPed = CreatePedInsideVehicle(docVeh, 26, GetHashKey('s_m_m_paramedic_01'), -1, true, false) 77 | local passengerPed = CreatePedInsideVehicle(docVeh, 26, GetHashKey('s_m_m_paramedic_01'), 0, true, false) 78 | docBlip = AddBlipForEntity(docVeh) 79 | SetBlipFlashes(docBlip, true) 80 | SetBlipColour(docBlip, 5) 81 | 82 | SetEntityInvincible(docPed, true) 83 | SetEntityInvincible(passengerPed, true) 84 | 85 | PlaySoundFrontend(-1, "Text_Arrive_Tone", "Phone_SoundSet_Default", 1) 86 | Wait(2000) 87 | 88 | local docDriver = GetPedInVehicleSeat(docVeh, -1) 89 | TaskVehicleDriveToCoord(docDriver, docVeh, loc.x, loc.y, loc.z, 20.0, 0, GetEntityModel(docVeh), 524863, 2.0) 90 | 91 | veh = docVeh 92 | ped1 = docPed 93 | ped2 = passengerPed 94 | Active = true 95 | docEnRoute() 96 | end 97 | 98 | function docEnRoute() 99 | while not Revived do 100 | sleep = 200 101 | local playerPed = GetPlayerPed(-1) 102 | local loc = GetEntityCoords(playerPed) 103 | local lc = GetEntityCoords(veh) 104 | local ld = GetEntityCoords(ped1) 105 | local dist = #(loc - lc) 106 | local dist1 = #(loc - ld) 107 | local time = GetGameTimer() 108 | local timer = (time - lastDoctorTime)/1000 109 | if Config.Debug then print('Doc En Route - Dist: '..dist, 'Dist1: '..dist1, 'Time: '..time, 'lastDoctorTime: '..lastDoctorTime, 'Timer: '..timer..' seconds') end 110 | if dist <= 10 then 111 | SetVehicleSiren(docVeh, false) 112 | if IsPedInAnyVehicle(playerPed, false) then 113 | local veh = GetVehiclePedIsIn(playerPed, false) 114 | TaskLeaveVehicle(playerPed, veh, 16) 115 | elseif Active then 116 | TaskGoToCoordAnyMeans(ped1, loc.x, loc.y, loc.z, 3.0, 0, 0, 786603, 0xbf800000) 117 | end 118 | if dist1 <= 1.5 then 119 | Active = false 120 | DoctorNPC() 121 | break 122 | end 123 | elseif lastDoctorTime > 0 and timer >= Config.TPTime then 124 | sleep = 3000 125 | SetVehicleSiren(docVeh, false) 126 | ClearPedTasksImmediately(ped1) 127 | if Config.Debug then print('TP to AI Doc Triggered') end 128 | if DoesEntityExist(ped1) then 129 | DoScreenFadeOut(500) 130 | SetEntityCoords(playerPed, ld.x + 5.0, ld.y + 5.0, ld.z, 0, 0, 0, 1) 131 | Wait(2500) 132 | DoScreenFadeIn(1500) 133 | lastDoctorTime = 0 134 | end 135 | end 136 | Wait(sleep) 137 | end 138 | end 139 | 140 | function DoctorNPC() 141 | if Config.Debug then print('DoctorNPC Triggered') end 142 | RequestAnimDict(ANIM_DICT) 143 | while not HasAnimDictLoaded(ANIM_DICT) do 144 | Wait(1000) 145 | end 146 | 147 | TaskPlayAnim(ped1, ANIM_DICT, "cpr_pumpchest", 1.0, 1.0, -1, 9, 1.0, 0, 0, 0) 148 | 149 | PlayAmbientSpeech1(ped1, "GENERIC_CURSE_HIGH", "SPEECH_PARAMS_FORCE", 3) 150 | Wait(2000) 151 | PlayAmbientSpeech1(ped2, "GENERIC_INSULT_HIGH", "SPEECH_PARAMS_FORCE", 3) 152 | 153 | QBCore.Functions.Progressbar("revive_doc", "HANG IN THERE BUDDY!!", REVIVE_TIME, false, false, { 154 | disableMovement = false, 155 | disableCarMovement = false, 156 | disableMouse = false, 157 | disableCombat = true, 158 | }, {}, {}, {}, function() 159 | ClearPedTasks(ped1) 160 | Wait(500) 161 | TriggerEvent("hospital:client:Revive") 162 | TriggerServerEvent('lb:charge') 163 | StopScreenEffect('DeathFailOut') 164 | QBCore.Functions.Notify("Your treatment is done, you were charged: $"..Config.Price, "success") 165 | TriggerServerEvent("qb-log:server:CreateLog", "commands", "Help Command Healed", "green", "Player **".. QBCore.Functions.GetPlayerData().name .. "** Character Name: **" .. QBCore.Functions.GetPlayerData().charinfo["firstname"] .. " " .. QBCore.Functions.GetPlayerData().charinfo["lastname"] .. "** was healed by the AI Doc.") 166 | calledHelp = false 167 | Revived = true 168 | 169 | --RemovePedElegantly(ped1) 170 | TaskEnterVehicle(ped1, veh, 0, 2, 3.0, 1, 0) 171 | TaskVehicleDriveWander(ped1, veh, 25.0, 524295) 172 | Wait(20000) 173 | DeleteEntity(veh) 174 | DeleteEntity(ped1) 175 | DeleteEntity(ped2) 176 | end) 177 | end 178 | 179 | AddEventHandler('onResourceStop', function(resource) 180 | if resource == GetCurrentResourceName() then 181 | DeleteEntity(veh) 182 | DeleteEntity(ped1) 183 | DeleteEntity(ped2) 184 | end 185 | end) 186 | --------------------------------------------------------------------------------