[Dev-Resource] Mythic Hospital (Body Part Damage & Healing)

Here is my client side edits. This is based on the first ESX copy of this made. This is not a updated Mythic Hospital. I dont need the updated one so i haven’t updated it. It will be up to you to copy the parts needed to your updated copy of the script.

MLO used for lower Pillbox is [Release] Pillbox Hospital Interior (MLO)

Again here is the video so you know what this is for. https://showmore.com/u/1iqbzrm

local blips = {
  {name="Hospital", id=80, x= 365.02, y= -591.64, z= 28.69, color= 1},
  --{name="Hospital", id=80, x= -449.67, y= -340.83, z= 33.50, color= 1},
}                              


Citizen.CreateThread(function()
  for _, item in pairs(blips) do
    item.blip = AddBlipForCoord(item.x, item.y, item.z)
    SetBlipSprite(item.blip, item.id)
    SetBlipColour(item.blip, item.color)
    SetBlipAsShortRange(item.blip, true)
    BeginTextCommandSetBlipName("STRING")
    AddTextComponentString(item.name)
    EndTextCommandSetBlipName(item.blip)
  end
end)






local hospitalCheckin = { x = 340.02, y = -585.85, z = 28.79, h = 65.86 }
local pillboxTeleports = {    
    { x = 325.48892211914, y = -598.75372314453, z = 43.291839599609, h = 64.513374328613, text = 'Press ~INPUT_CONTEXT~ ~s~to go to lower Pillbox Entrance' },
    { x = 355.47183227539, y = -596.26495361328, z = 28.773477554321, h = 245.85662841797, text = 'Press ~INPUT_CONTEXT~ ~s~to enter Pillbox Hospital' },
    { x = 359.57849121094, y = -584.90911865234, z = 28.817169189453, h = 245.85662841797, text = 'Press ~INPUT_CONTEXT~ ~s~to enter Pillbox Hospital' },
}

local bedOccupying = nil
local bedOccupyingData = nil

local cam = nil

local inBedDict = "anim@gangops@morgue@table@"
local inBedAnim = "ko_front"
local getOutDict = 'switch@franklin@bed'
local getOutAnim = 'sleep_getup_rubeyes'
ESX = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

function PrintHelpText(message)
    SetTextComponentFormat("STRING")
    AddTextComponentString(message)
    DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

function LeaveBed()
    RequestAnimDict(getOutDict)
    while not HasAnimDictLoaded(getOutDict) do
        Citizen.Wait(0)
    end

    RenderScriptCams(0, true, 200, true, true)
    DestroyCam(cam, false)

    SetEntityHeading(PlayerPedId(), bedOccupyingData.h - 90)
    TaskPlayAnim(PlayerPedId(), getOutDict , getOutAnim ,8.0, -8.0, -1, 0, 0, false, false, false )
    Citizen.Wait(5000)
    ClearPedTasks(PlayerPedId())
    FreezeEntityPosition(PlayerPedId(), false)
    TriggerServerEvent('mythic_hospital:server:LeaveBed', bedOccupying)

    bedOccupying = nil
    bedOccupyingData = nil
end

RegisterNetEvent('mythic_hospital:client:RPCheckPos')
AddEventHandler('mythic_hospital:client:RPCheckPos', function()
    TriggerServerEvent('mythic_hospital:server:RPRequestBed', GetEntityCoords(PlayerPedId()))
end)

RegisterNetEvent('mythic_hospital:client:RPSendToBed')
AddEventHandler('mythic_hospital:client:RPSendToBed', function(id, data)
    bedOccupying = id
    bedOccupyingData = data
    SetEntityCoords(PlayerPedId(), data.x, data.y, data.z - 0.5)
    
    RequestAnimDict(inBedDict)
    while not HasAnimDictLoaded(inBedDict) do
        Citizen.Wait(0)
    end

    TaskPlayAnim(PlayerPedId(), inBedDict , inBedAnim ,8.0, -8.0, -1, 1, 0, false, false, false )
    SetEntityHeading(PlayerPedId(), data.h + 180)

    cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
    SetCamActive(cam, true)
    RenderScriptCams(true, false, 1, true, true)
    AttachCamToPedBone(cam, PlayerPedId(), 31085, 0, 0, 1.0 , true)
    SetCamFov(cam, 90.0)
    SetCamRot(cam, -90.0, 0.0, GetEntityHeading(PlayerPedId()) + 180, true)
            

    Citizen.CreateThread(function()
        while bedOccupyingData ~= nil do
            Citizen.Wait(1)
            PrintHelpText('Press ~INPUT_VEH_DUCK~ to get up')
            if IsControlJustReleased(0, 73) then
                LeaveBed()
            end
        end
    end)
end)

RegisterNetEvent('mythic_hospital:client:SendNurse')   ---new added for nurse to spawn and walk you to your bed
AddEventHandler('mythic_hospital:client:SendNurse', function(id, data)

			--Citizen.Wait(1000)
			--nped = CreatePed(4, "csb_mweather", x1, y1, z1, 0.0, true, true)
			SpawnedPed = CreatePed(4,"s_m_m_doctor_01", 333.69, -581.89, 28.79, 236.08, true, true)
			
			Citizen.Wait(2000)
			TaskGoStraightToCoord(SpawnedPed, 341.64, -584.85, 28.79, 1.0, -1, 340.92, 0.0)
			Citizen.Wait(6000)
			TaskGoStraightToCoord(SpawnedPed, 348.01, -563.28, 28.79, 1.0, -1, 244.15, 0.0)
			Citizen.Wait(14000)
			TaskGoStraightToCoord(SpawnedPed, 344.24, -572.21, 28.79, 1.0, -1, 71.92, 0.0)
			Citizen.Wait(8000)
			TaskGoStraightToCoord(SpawnedPed, 335.08, -568.12, 28.79, 1.0, -1, 64.62, 0.0)
			Citizen.Wait(15000)
			DeletePed(SpawnedPed)

end)

Citizen.CreateThread(function()
    
    RequestModel(GetHashKey("s_m_m_doctor_01"))
    while not HasModelLoaded(GetHashKey("s_m_m_doctor_01")) do
      Wait(1)
    end

      local hospitalped =  CreatePed(4, 0xd47303ac, 338.72, -585.27, 27.79, 244.48, false, true)
      SetEntityHeading(hospitalped, 244.48)
      FreezeEntityPosition(hospitalped, true)
      SetEntityInvincible(hospitalped, true)
      SetBlockingOfNonTemporaryEvents(hospitalped, true)
end)


RegisterNetEvent('mythic_hospital:client:SendToBed')  edited for you to walk to you bed and then get in it
AddEventHandler('mythic_hospital:client:SendToBed', function(id, data)
    bedOccupying = id
    bedOccupyingData = data
	local playerPed = PlayerPedId()
	TriggerEvent('mythic_hospital:client:SendNurse')
		Citizen.Wait(7000)
	exports['mythic_notify']:DoHudText('inform', 'Please follow the nurse!')
		Citizen.Wait(2000)
		TaskGoStraightToCoord(playerPed, 349.13, -562.65, 28.79, 1.0, -1, 263.74, 0.0)
		Citizen.Wait(15000)
		TaskGoStraightToCoord(playerPed, 353.59, -563.88, 28.79, 1.0, -1, 188.66, 0.0)
		Citizen.Wait(2000)
    SetEntityCoords(PlayerPedId(), data.x, data.y, data.z - 0.3)
    RequestAnimDict(inBedDict)
    while not HasAnimDictLoaded(inBedDict) do
        Citizen.Wait(0)
		
    end
    TaskPlayAnim(PlayerPedId(), inBedDict , inBedAnim ,8.0, -8.0, -1, 1, 0, false, false, false )
    SetEntityHeading(PlayerPedId(), data.h + 180)

    cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1)
    SetCamActive(cam, true)
    RenderScriptCams(true, false, 1, true, true)
    AttachCamToPedBone(cam, PlayerPedId(), 31085, 0, 0, 1.0 , true)
    SetCamFov(cam, 90.0)
    SetCamRot(cam, -90.0, 0.0, GetEntityHeading(PlayerPedId()) + 180, true)

    Citizen.CreateThread(function ()
        Citizen.Wait(5)
        local player = PlayerPedId()

        exports['mythic_notify']:DoHudText('inform', 'Doctors Are Treating You')
        Citizen.Wait(5000)
		  SendNUIMessage({
		     displayWindow = 'false'
		     })
		  isUiOpen = true
		  Citizen.Wait(15000)
		  
		  Citizen.Wait(90000)
                TriggerServerEvent('mythic_hospital:server:EnteredBed')
    end)
end)

RegisterNetEvent('mythic_hospital:client:FinishServices')  --edited for you to walk out of bed and back to lobby
AddEventHandler('mythic_hospital:client:FinishServices', function()
	local playerPed = PlayerPedId()
	SetEntityHealth(PlayerPedId(), GetEntityMaxHealth(PlayerPedId()))
    TriggerEvent('mythic_hospital:client:RemoveBleed')
    TriggerEvent('mythic_hospital:client:ResetLimbs')
    exports['mythic_notify']:DoHudText('inform', 'You\'ve Been Treated & Billed')
    LeaveBed()
	Citizen.Wait(3000)
	TaskGoStraightToCoord(playerPed, 352.41, -563.52, 28.79, 1.0, -1, 324.15, 0.0)
	Citizen.Wait(4000)
	TaskGoStraightToCoord(playerPed, 346.43, -567.04, 28.79, 1.0, -1, 120.74, 0.0)
	Citizen.Wait(4000)
	TaskGoStraightToCoord(playerPed, 341.22, -577.87, 28.79, 1.0, -1, 212.89, 0.0)
end)

RegisterNetEvent('mythic_hospital:client:ForceLeaveBed')
AddEventHandler('mythic_hospital:client:ForceLeaveBed', function()
    LeaveBed()
end)
---Make Damage Persistant (Disable Auto-Heal)
SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(1)
			local plyCoords = GetEntityCoords(PlayerPedId(), 0)
            local distance = #(vector3(hospitalCheckin.x, hospitalCheckin.y, hospitalCheckin.z) - plyCoords)
            if distance < 10 then
                --DrawMarker(27, hospitalCheckin.x, hospitalCheckin.y, hospitalCheckin.z - 0.99, 0, 0, 0, 0, 0, 0, 0.5, 0.5, 1.0, 1, 157, 0, 155, false, false, 2, false, false, false, false)

                if not IsPedInAnyVehicle(PlayerPedId(), true) then
                    if distance < 1 then
                        --PrintHelpText('Press ~INPUT_CONTEXT~ ~s~to check in')
			ESX.Game.Utils.DrawText3D(vector3(hospitalCheckin.x, hospitalCheckin.y, hospitalCheckin.z + 0.5), '[E] Check in', 0.4)
                        if IsControlJustReleased(0, 54) then
                            if (GetEntityHealth(PlayerPedId()) < 300) or (IsInjuredOrBleeding()) then
                                exports['mythic_progbar']:Progress({
                                    name = "hospital_action",
                                    duration = 10500,
                                    label = "Checking In",
                                    useWhileDead = false,
                                    canCancel = true,
                                    controlDisables = {
                                        disableMovement = true,
                                        disableCarMovement = true,
                                        disableMouse = false,
                                        disableCombat = true,
                                    },
                                    animation = {
                                        animDict = "missheistdockssetup1clipboard@base",
                                        anim = "base",
                                        flags = 49,
                                    },
                                    prop = {
                                        model = "p_amb_clipboard_01",
                                        bone = 18905,
										coords = { x = 0.10, y = 0.02, z = 0.08 },
										rotation = { x = -80.0, y = 0.0, z = 0.0 },
                                    },
                                    propTwo = {
                                        model = "prop_pencil_01",
                                        bone = 58866,
										coords = { x = 0.12, y = 0.0, z = 0.001 },
										rotation = { x = -150.0, y = 0.0, z = 0.0 },
                                    },
                                }, function(status)
                                    if not status then
                                        TriggerServerEvent('mythic_hospital:server:RequestBed')
                                    end
                                end)
                            else
                                exports['mythic_notify']:DoHudText('error', 'You do not need medical attention')
                            end
                        end
                    end
                end
            else
                Citizen.Wait(1000)
            end
    end
end)
2 Likes