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

Here’s the wound.lua server file

local playerInjury = {}

function GetCharsInjuries(source)
return playerInjury[source]
end

RegisterServerEvent(‘mythic_hospital:server:SyncInjuries’)
AddEventHandler(‘mythic_hospital:server:SyncInjuries’, function(data)
local src = source
local char = exports[‘mythic_base’]:getPlayerFromId(src).getChar()
local cData = char.getCharData()

playerInjury[cData.id] = data

end)

Also, I found weird error. My character is wounded but player heal increased.

1 Like

Could you copy where the timer on the notifications are for you if you changed them?
Yours seem to stay up in the corner and don’t disapear

It’s not working because you didn’t replace it with one of the above solutions, replace the entirety of the mythic_hospital:server:SyncInjuries event with

RegisterServerEvent('mythic_hospital:server:SyncInjuries')
AddEventHandler('mythic_hospital:server:SyncInjuries', function(data)
    playerInjury[source] = data
end)

That’s default GTA 5’s health regen afaik, add SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0) to a client script (Only need to run it once)

2 Likes

Like this since i’m running ESX?

local playerInjury = {}
ESX = nil

TriggerEvent(‘esx:getSharedObject’, function(obj) ESX = obj end)

function GetCharsInjuries(source)
return playerInjury[source]
end

RegisterServerEvent(‘mythic_hospital:server:SyncInjuries’)
AddEventHandler(‘mythic_hospital:server:SyncInjuries’, function(data)
playerInjury[source] = data
end)

Should work, yes.

Hmm, there is one i see now in F8

the error resuming one
Imgur

Try to download latest code from GitHub

1 Like

OMG I love you
Thank You soooo much.

That helped + now i also get treated and gets a heal when checking in.

Btw, can you also post where to change the duration on the notifications?
They went away kinda to quicly. I would like to have them up a little longer

in client/wound.lua;

Line # 564 for injury status

exports['mythic_notify']:DoCustomHudText('inform', str, 15000)

Line # 598 For Bleeding State

exports['mythic_notify']:DoCustomHudText('inform', 'You Have ' .. BleedingStates[isBleeding], 25000)
2 Likes

Thank You:heart:

Keep Up the good work my man:slightly_smiling_face:

Btw
Do you know how to get to use the Pink Cage Motel
Like open it up for players to have rooms, etc

1 Like

everything works great up until we lay down on the bed, then were stuck there and it throws an error

Error resuming coroutine: @mythic_hospital/server/main.lua:72: attempt to index a nil value (local ‘injuries’)

Latest Pull and Followed along with all of the above to no avail. Any thoughts?

Line 72:

local injuries = GetCharsInjuries(src)

Post your GetCharsInjuries function (server/wounds.lua)

function GetCharsInjuries(source)
return playerInjury[source]
end

me too.

By chance, do they not have any limb damage and just trying to heal their HP? Just realized there is an error with that. Will push a fix that will hopefully fix this for you

Yes, they were taking fall damage and testing it, im guessing id have to add the complete body index to include all the parts they could be injuring? (ie, face, eyebrow, lips) etc?

If you change

        for k, v in pairs(injuries.limbs) do
            if v.isDamaged then
                totalBill = totalBill + (injuryBasePrice * v.severity)
            end
        end

        if injuries.isBleeding > 0 then
            totalBill = totalBill + (injuryBasePrice * injuries.isBleeding)
        end

With

    if injuries ~= nil then
        for k, v in pairs(injuries.limbs) do
            if v.isDamaged then
                totalBill = totalBill + (injuryBasePrice * v.severity)
            end
        end

        if injuries.isBleeding > 0 then
            totalBill = totalBill + (injuryBasePrice * injuries.isBleeding)
        end
    end

Does it fix it?

I dont get any bill when I treated.

In The OP ^