diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 30892e2f..e2d69608 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -538,10 +538,12 @@ void CCSPlayer::Reset() m_iWeaponInfiniteAmmo = 0; m_iWeaponInfiniteIds = 0; m_bCanShootOverride = false; + m_bGameForcingRespawn = false; } void CCSPlayer::OnSpawn() { + m_bGameForcingRespawn = false; m_flRespawnPending = 0.0f; } @@ -550,6 +552,7 @@ void CCSPlayer::OnKilled() #ifdef REGAMEDLL_ADD if (forcerespawn.value > 0) { + m_bGameForcingRespawn = true; m_flRespawnPending = gpGlobals->time + forcerespawn.value; } diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 87cc3835..a5949ff0 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -9935,10 +9935,13 @@ void CBasePlayer::PlayerRespawnThink() if (pev->deadflag < DEAD_DYING) return; - if (forcerespawn.value > 0 && - CSPlayer()->m_flRespawnPending > 0 && + if (CSPlayer()->m_flRespawnPending > 0 && CSPlayer()->m_flRespawnPending <= gpGlobals->time) { + // Pending respawn caused by game doesn't respawn with disabled CVar + if (CSPlayer()->m_bGameForcingRespawn && !forcerespawn.value) + return; + Spawn(); pev->button = 0; pev->nextthink = -1; diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 33678185..5020585a 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -45,7 +45,8 @@ public: m_flSpawnProtectionEndTime(0), m_iWeaponInfiniteAmmo(0), m_iWeaponInfiniteIds(0), - m_bCanShootOverride(false) + m_bCanShootOverride(false), + m_bGameForcingRespawn(false) { m_szModel[0] = '\0'; } @@ -123,6 +124,7 @@ public: int m_iWeaponInfiniteAmmo; int m_iWeaponInfiniteIds; bool m_bCanShootOverride; + bool m_bGameForcingRespawn; }; // Inlines