[JS] Coma state problem

hello guys, really strange stuff happening here (at least for me), i’m trying to make a coma state and i can’t understand why sometimes it works fine, sometimes it doesnt. for example, when i fall down and go into the coma state, the healme command revives me but if someone shoots me, i go into the coma state, i use healme, it heals me for a fraction of a seccond and then it turns back to coma state, i’ve been trying to figure out what’s going on since the morning and i can’t

 setTick(() => {
    SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0)
    if (GetEntityHealth(PlayerPedId()) <= 105) {
        SetEntityHealth(PlayerPedId(), 110)
        SetEntityInvincible(GetPlayerPed(-1), true)
        StartScreenEffect("DeathFailOut", 0, 1)
    }

    if (GetEntityHealth(PlayerPedId()) == 110) {
        if (IsPedInAnyVehicle(PlayerPedId(), true) == true) {
            TaskLeaveAnyVehicle(PlayerPedId(), true, true)
        }
        SetPedToRagdoll(PlayerPedId(), 300000, 1000, 0, true, true, false)
        StartScreenEffect("DeathFailOut", 0, 1)
    }
})

RegisterCommand('healme', function () {
    SetEntityHealth(PlayerPedId(), 200)
    thirst = 200;
    hunger = 200;
    SetEntityInvincible(PlayerPedId(), false)
    SetPedToRagdoll(PlayerPedId(), 1, 1, 0, true, true, false)
    StartScreenEffect("DeathFailOut", 1, 0)
    SendNuiMessage(JSON.stringify({
        type: "htc",
        sendhunger: hunger,
        sendthirst: thirst
    }))
}) 
1 Like

The problem is solved, you can close the topic.

setTick(() => {
    SetPlayerHealthRechargeMultiplier(PlayerId(), 0.0)
    if (comaStatus == false && GetEntityHealth(PlayerPedId()) <= 105) {
        if (IsEntityDead(GetPlayerPed(-1)) == true) {
            let deathLocation = GetEntityCoords(PlayerPedId());
            NetworkResurrectLocalPlayer(deathLocation[0], deathLocation[1], deathLocation[2], true, true, false)
        }
        setTimeout(() => {
            comaStatus = true
        }, 10)
    }

    if (comaStatus == true) {
        SetEntityHealth(PlayerPedId(), 110)
        SetEntityInvincible(GetPlayerPed(-1), true)
        StartScreenEffect("DeathFailOut", 0, 1)
        if (IsPedInAnyVehicle(PlayerPedId(), true) == true) {
            TaskLeaveAnyVehicle(PlayerPedId(), true, true)
        }
        SetPedToRagdoll(PlayerPedId(), 300000, 1000, 0, true, true, false)
    }
})


RegisterCommand('healme', function () {
        setTimeout(()=> {
            SetEntityHealth(PlayerPedId(), 200)
            thirst = 200;
            hunger = 200;
            SetEntityInvincible(GetPlayerPed(-1), false)
            SetPedToRagdoll(PlayerPedId(), 1, 1, 0, true, true, false)
            StartScreenEffect("DeathFailOut", 1, 0)
            SendNuiMessage(JSON.stringify({
                type: "htc",
                sendhunger: hunger,
                sendthirst: thirst
            }))
            comaStatus = false;
        },50)
})
1 Like