diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 98e11fc2..8d209b31 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -166,6 +166,7 @@ GAMEHOOK_REGISTRY(CBasePlayerWeapon_CanDeploy); GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultDeploy); GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultReload); GAMEHOOK_REGISTRY(CBasePlayerWeapon_DefaultShotgunReload); +GAMEHOOK_REGISTRY(CBasePlayer_DropIdlePlayer); int CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index cd7df97b..2f9020bb 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -563,6 +563,10 @@ typedef IHookChainRegistryClassImpl CRe typedef IHookChainClassImpl CReGameHook_CBasePlayerWeapon_DefaultShotgunReload; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload; +// CBasePlayer::DropIdlePlayer hook +typedef IHookChainClassImpl CReGameHook_CBasePlayer_DropIdlePlayer; +typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_DropIdlePlayer; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -676,6 +680,7 @@ public: CReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy m_CBasePlayerWeapon_DefaultDeploy; CReGameHookRegistry_CBasePlayerWeapon_DefaultReload m_CBasePlayerWeapon_DefaultReload; CReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload m_CBasePlayerWeapon_DefaultShotgunReload; + CReGameHookRegistry_CBasePlayer_DropIdlePlayer m_CBasePlayer_DropIdlePlayer; public: virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); @@ -788,6 +793,7 @@ public: virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy *CBasePlayerWeapon_DefaultDeploy(); virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultReload *CBasePlayerWeapon_DefaultReload(); virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload(); + virtual IReGameHookRegistry_CBasePlayer_DropIdlePlayer *CBasePlayer_DropIdlePlayer(); }; extern CReGameHookchains g_ReGameHookchains; diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index becb4ca9..32ab60f4 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -4316,26 +4316,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)() real_t flLastMove = gpGlobals->time - m_fLastMovement; //check if this player has been inactive for 2 rounds straight - if (flLastMove > CSGameRules()->m_fMaxIdlePeriod) + if (!IsBot() && flLastMove > CSGameRules()->m_fMaxIdlePeriod) { - if (!IsBot() && autokick.value) - { - // Log the kick - UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam)); - UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); - -#ifdef REGAMEDLL_FIXES - int iUserID = GETPLAYERUSERID(edict()); - if (iUserID != -1) - { - SERVER_COMMAND(UTIL_VarArgs("kick #%d \"Player idle\"\n", iUserID)); - } -#else - SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); -#endif // #ifdef REGAMEDLL_FIXES - - m_fLastMovement = gpGlobals->time; - } + DropIdlePlayer("Player idle"); + + m_fLastMovement = gpGlobals->time; } #ifdef REGAMEDLL_ADD if (afk_bomb_drop_time.value > 0.0 && IsBombGuy()) @@ -9921,3 +9906,28 @@ void CBasePlayer::__API_HOOK(RemoveSpawnProtection)() CSPlayer()->m_flSpawnProtectionEndTime = 0.0f; } + +LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, DropIdlePlayer, (const char *reason), reason) + +void EXT_FUNC CBasePlayer::__API_HOOK(DropIdlePlayer)(const char *reason) +{ + if (!autokick.value) + return; + + edict_t *pEntity = edict(); + + int iUserID = GETPLAYERUSERID(pEntity); + + // Log the kick + UTIL_LogPrintf("\"%s<%i><%s><%s>\" triggered \"Game_idle_kick\" (auto)\n", STRING(pev->netname), iUserID , GETPLAYERAUTHID(pEntity), GetTeam(m_iTeam)); + UTIL_ClientPrintAll(HUD_PRINTCONSOLE, "#Game_idle_kick", STRING(pev->netname)); + +#ifdef REGAMEDLL_FIXES + if (iUserID != -1) + { + SERVER_COMMAND(UTIL_VarArgs("kick #%d \"%s\"\n", iUserID, reason)); + } +#else + SERVER_COMMAND(UTIL_VarArgs("kick \"%s\"\n", STRING(pev->netname))); +#endif // #ifdef REGAMEDLL_FIXES +} diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 20c31a78..3c706091 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -429,6 +429,7 @@ public: void RemoveSpawnProtection_OrigFunc(); bool HintMessageEx_OrigFunc(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); void UseEmpty_OrigFunc(); + void DropIdlePlayer_OrigFunc(const char *reason); CCSPlayer *CSPlayer() const; #endif // REGAMEDLL_API @@ -625,6 +626,7 @@ public: void SetSpawnProtection(float flProtectionTime); void RemoveSpawnProtection(); void UseEmpty(); + void DropIdlePlayer(const char *reason); // templates template diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index e05bab42..8c8e56dc 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -460,6 +460,10 @@ typedef IHookChainRegistryClass I typedef IHookChainClass IReGameHook_CBasePlayerWeapon_DefaultShotgunReload; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload; +// CBasePlayer::DropIdlePlayer hook +typedef IHookChainClass IReGameHook_CBasePlayer_DropIdlePlayer; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_DropIdlePlayer; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -574,6 +578,7 @@ public: virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultDeploy *CBasePlayerWeapon_DefaultDeploy() = 0; virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultReload *CBasePlayerWeapon_DefaultReload() = 0; virtual IReGameHookRegistry_CBasePlayerWeapon_DefaultShotgunReload *CBasePlayerWeapon_DefaultShotgunReload() = 0; + virtual IReGameHookRegistry_CBasePlayer_DropIdlePlayer *CBasePlayer_DropIdlePlayer() = 0; }; struct ReGameFuncs_t {