qbcore-framework / qb-ambulancejob

Ambulance Job, Hospital System & Death System For QB-Core :man_health_worker: :woman_health_worker:
GNU General Public License v3.0
34 stars 283 forks source link

[BUG] Regen auto under 50% of health #246

Closed xhackax47 closed 2 years ago

xhackax47 commented 2 years ago

Describe the bug When every player go under 50% of health with injury, it automatically regen to 50% always until the player disconnect.

To Reproduce Steps to reproduce the behavior:

  1. Take bullets or /setpain
  2. Wait to die and /revive and repeat until the bug occurs (few times, sometimes one try is sufficient to make the bug)
  3. Even when i go to checkin hospital or /revive or /kill the player, the regen remains. (have to disconnect)
  4. I dont know if the bug appears when last stand? kill? wounding? i dont know i searched and modify a lot and found nothing but i noticed that the laststand position remains at 50% health vs death stand 100% health when i make appears the names.

Expected behavior Just not automatically regen?

Screenshots image Moment of death (0% health) image Last stand (50% health) image Death stand (100% health)

Questions (please complete the following information):

xhackax47 commented 2 years ago

I just noticed the regen is fastest when i dont move but continue whatever i do/did Someone know how i can disable this? Ever noticed the "SetPlayerHealthRechargeMultiplier(player, 0.0) and SetPlayerHealthRechargeLimit(player, 0.0) so i dont understand

RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
    exports.spawnmanager:setAutoSpawn(false)
    local ped = PlayerPedId()
    local player = PlayerId()
    CreateThread(function()
        Wait(5000)
        SetEntityMaxHealth(ped, 200)
        SetEntityHealth(ped, 200)
        SetPlayerHealthRechargeMultiplier(player, 0.0)
        SetPlayerHealthRechargeLimit(player, 0.0)
    end)
    CreateThread(function()
        Wait(1000)
        QBCore.Functions.GetPlayerData(function(PlayerData)
            PlayerJob = PlayerData.job
            onDuty = PlayerData.job.onduty
            SetPedArmour(PlayerPedId(), PlayerData.metadata["armor"])
            if (not PlayerData.metadata["inlaststand"] and PlayerData.metadata["isdead"]) then
                deathTime = Laststand.ReviveInterval
                OnDeath()
                DeathTimer()
            elseif (PlayerData.metadata["inlaststand"] and not PlayerData.metadata["isdead"]) then
                SetLaststand(true)
            else
                TriggerServerEvent("hospital:server:SetDeathStatus", false)
                TriggerServerEvent("hospital:server:SetLaststandStatus", false)
            end
            if PlayerJob.name == 'ambulance' and onDuty then
                TriggerServerEvent("hospital:server:AddDoctor", PlayerJob.name)
            end
        end)
    end)
end)
xhackax47 commented 2 years ago

Fixed here