esx-framework / esx_core

Official Repo For core resources for esx-legacy
https://documentation.esx-framework.org/
GNU General Public License v3.0
362 stars 733 forks source link

[Bug] - es_extended - After relog, player are not recognized as dead #1297

Closed iSentrie closed 7 months ago

iSentrie commented 7 months ago

When player dies and does reconnect, he's not recognized as dead and dead player cannot call for emergency services also can't see respawn/bleedout timer.

To Reproduce

  1. Die
  2. Quit game
  3. Connect back to game
  4. Player won't receive option to call for emergency or see timer until respawn.

Debug Info:

image

Gellipapa commented 7 months ago

@iSentrie Hi! Thank you for report issue. Is there any modification within es_extended in your client/main.lua esx:playerLoaded event?

iSentrie commented 7 months ago

@iSentrie Hi! Thank you for report issue. Is there any modification within es_extended in your client/main.lua esx:playerLoaded event?

No, 1:1, not modified, however I updated only es_extended, if any other resource could have impact to this, then it might be on my side.

Like, hm, the issue is actually with esx_ambulancejob, because this script doesn't show respawn timer, so a bit tricky to choose where to look for an issue, but my guess is that metadata stuff kills player so fast, that not all data have been received at that time in other resources?

Gellipapa commented 7 months ago

@iSentrie Hi! Thank you for report issue. Is there any modification within es_extended in your client/main.lua esx:playerLoaded event?

No, 1:1, not modified, however I updated only es_extended, if any other resource could have impact to this, then it might be on my side.

Like, hm, the issue is actually with esx_ambulancejob, because this script doesn't show respawn timer, so a bit tricky to choose where to look for an issue, but my guess is that metadata stuff kills player so fast, that not all data have been received at that time in other resources?

We found the problem because it doesn't use multichart, so there is no delay, and the metadata ped setup runs before the actual ped spawn, and that's the problem.

iSentrie commented 7 months ago

So the plan is to use "3000" delay for both, not just multichar? Like so

RegisterNetEvent("esx:playerLoaded")
AddEventHandler("esx:playerLoaded", function(xPlayer, isNew, skin)
    ESX.PlayerData = xPlayer

    if not Config.Multichar then
        exports.spawnmanager:spawnPlayer({
            x = ESX.PlayerData.coords.x,
            y = ESX.PlayerData.coords.y,
            z = ESX.PlayerData.coords.z + 0.25,
            heading = ESX.PlayerData.coords.heading,
            model = `mp_m_freemode_01`,
            skipFade = false,
        }, function()
            TriggerServerEvent("esx:onPlayerSpawn")
            TriggerEvent("esx:onPlayerSpawn")
            TriggerEvent("esx:restoreLoadout")

            if isNew then
                TriggerEvent("skinchanger:loadDefaultModel", skin.sex == 0)
            elseif skin then
                TriggerEvent("skinchanger:loadSkin", skin)
            end

            TriggerEvent("esx:loadingScreenOff")
            ShutdownLoadingScreen()
            ShutdownLoadingScreenNui()
        end)
    end

    Wait(3000)
    ESX.PlayerLoaded = true

If that wont lead to vulnerabilities... Maybe better solution would be to use a handler skinchanger:modelLoaded 🤔

Gellipapa commented 7 months ago

@iSentrie Hi! We have fixed the reported issue and released the latest version 1.10.4 which includes this fix.