From 548cca5e5f16745a8cf598251291745ada6c2788 Mon Sep 17 00:00:00 2001 From: Vaqtincha <51029683+Vaqtincha@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:16:09 +0500 Subject: [PATCH] Forcerespawn fix (#623) * Dead players now respawn after enabling the mp_forcerespawn * use timer instead of instant spawn --- regamedll/dlls/player.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index e3cac4fc..14f1a4ec 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -10053,18 +10053,30 @@ void CBasePlayer::PlayerRespawnThink() if (pev->deadflag < DEAD_DYING) return; - if (CSPlayer()->m_flRespawnPending > 0 && - CSPlayer()->m_flRespawnPending <= gpGlobals->time) + if (CSPlayer()->m_flRespawnPending > 0) { - // Pending respawn caused by game doesn't respawn with disabled CVar - if (CSPlayer()->m_bGameForcingRespawn && !forcerespawn.value) - return; + if (CSPlayer()->m_flRespawnPending <= gpGlobals->time) + { + // Pending respawn caused by game doesn't respawn with disabled CVar + if (CSPlayer()->m_bGameForcingRespawn && !forcerespawn.value) + { + CSPlayer()->m_flRespawnPending = 0.0f; + CSPlayer()->m_bGameForcingRespawn = false; + return; + } - Spawn(); - pev->button = 0; - pev->nextthink = -1; - return; + Spawn(); + pev->button = 0; + pev->nextthink = -1; + return; + } } + else if (pev->deadflag == DEAD_DEAD && forcerespawn.value > 0) + { + CSPlayer()->m_bGameForcingRespawn = true; + CSPlayer()->m_flRespawnPending = gpGlobals->time + forcerespawn.value; + } + #endif }