From eb2021827c34a5a46de674810bf0236adadd4a2d Mon Sep 17 00:00:00 2001 From: dystopm Date: Tue, 7 Jan 2025 00:22:36 -0300 Subject: [PATCH 1/4] Implement SendSayMessage hook --- .../amxmodx/scripting/include/reapi_gamedll_const.inc | 6 ++++++ reapi/include/cssdk/dlls/regamedll_api.h | 6 ++++++ reapi/msvc/reapi.vcxproj | 3 ++- reapi/src/hook_callback.cpp | 10 ++++++++++ reapi/src/hook_callback.h | 1 + reapi/src/hook_list.cpp | 1 + reapi/src/hook_list.h | 1 + 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index a0a860c4..0d75a478 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -487,6 +487,12 @@ enum GamedllFunc * Params: (const pPlayer, iSlot) */ RG_BuyItem, + + /* + * Description: Called when player says a message in server chat (say and say_team) + * Params: (const pPlayer, bool:teamonly, const szText[], const pszFormat[], const pszConsoleFormat[], bool:bSenderDead, const placeName[], bool:consoleUsesPlaceName) + */ + RG_SendSayMessage, }; /** diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index c0aa993a..9487e679 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -630,6 +630,10 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa typedef IHookChainClass IReGameHook_CBasePlayer_RemoveAllItems; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemoveAllItems; +// SendSayMessage hook +typedef IHookChain IReGameHook_SendSayMessage; +typedef IHookChainRegistry IReGameHookRegistry_SendSayMessage; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -792,6 +796,8 @@ class IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_PlayerDeathThink *CBasePlayer_PlayerDeathThink() = 0; virtual IReGameHookRegistry_CBasePlayer_Observer_Think *CBasePlayer_Observer_Think() = 0; virtual IReGameHookRegistry_CBasePlayer_RemoveAllItems *CBasePlayer_RemoveAllItems() = 0; + + virtual IReGameHookRegistry_SendSayMessage *SendSayMessage() = 0; }; struct ReGameFuncs_t { diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 4f753b31..2ca9754a 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -319,12 +319,13 @@ {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC} Win32Proj reapi + 10.0 DynamicLibrary true - v140_xp + v143 MultiByte diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index fb228ad6..eb5d1a1f 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1766,6 +1766,16 @@ void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chai callVoidForward(RG_CSGameRules_SendDeathMessage, original, indexOfPDataAmx(pKiller), indexOfEdict(pVictim->pev), indexOfPDataAmx(pAssister), indexOfEdictAmx(pevInflictor), killerWeaponName, iDeathMessageFlags, iRarityOfKill); } +void SendSayMessage(IReGameHook_SendSayMessage *chain, CBasePlayer *pPlayer, BOOL teamonly, char *p, const char *pszFormat, char *pszConsoleFormat, bool bSenderDead, const char *placeName, bool consoleUsesPlaceName) +{ + auto original = [chain](int _pPlayer, BOOL _teamonly, char *_p, const char *_pszFormat, char *_pszConsoleFormat, bool _bSenderDead, const char *_placeName, bool _consoleUsesPlaceName) + { + chain->callNext(getPrivate(_pPlayer), _teamonly, _p, _pszFormat, _pszConsoleFormat, _bSenderDead, _placeName, _consoleUsesPlaceName); + }; + + callVoidForward(RG_SendSayMessage, original, indexOfEdict(pPlayer->pev), teamonly, p, pszFormat, pszConsoleFormat, bSenderDead, placeName, consoleUsesPlaceName); +} + /* * VTC functions */ diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 3e3733a3..b00dc03a 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -574,6 +574,7 @@ void CBasePlayer_PlayerDeathThink(IReGameHook_CBasePlayer_PlayerDeathThink *chai void CBasePlayer_Observer_Think(IReGameHook_CBasePlayer_Observer_Think *chain, CBasePlayer *pthis); void CBasePlayer_RemoveAllItems(IReGameHook_CBasePlayer_RemoveAllItems *chain, CBasePlayer *pthis, BOOL removeSuit); void CSGameRules_SendDeathMessage(IReGameHook_CSGameRules_SendDeathMessage *chain, CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, entvars_t *pevInflictor, const char *killerWeaponName, int iDeathMessageFlags, int iRarityOfKill); +void SendSayMessage(IReGameHook_SendSayMessage *chain, CBasePlayer *pPlayer, BOOL teamonly, char *p, const char *pszFormat, char *pszConsoleFormat, bool bSenderDead, const char *placeName, bool consoleUsesPlaceName); /* * VTC functions diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index df094509..46312f14 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -145,6 +145,7 @@ hook_t hooklist_gamedll[] = { DLL(AddMultiDamage), DLL(ApplyMultiDamage), DLL(BuyItem), + DLL(SendSayMessage), }; hook_t hooklist_animating[] = { diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index 1618afd4..f98bd649 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -161,6 +161,7 @@ enum GamedllFunc RG_AddMultiDamage, RG_ApplyMultiDamage, RG_BuyItem, + RG_SendSayMessage, // [...] }; From e3cfc3d47b7e0c60b30c6fefcfd0d3595dbd754e Mon Sep 17 00:00:00 2001 From: dystopm Date: Tue, 7 Jan 2025 00:26:01 -0300 Subject: [PATCH 2/4] Update reapi.vcxproj --- reapi/msvc/reapi.vcxproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 2ca9754a..4f753b31 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -319,13 +319,12 @@ {74E2532F-BE55-4B2B-8C34-C9A4B5EC11AC} Win32Proj reapi - 10.0 DynamicLibrary true - v143 + v140_xp MultiByte From 4bb1ae4bee0f49ae5b289702c496ef7cff8eb8f5 Mon Sep 17 00:00:00 2001 From: dystopm Date: Sat, 20 Dec 2025 19:32:51 -0300 Subject: [PATCH 3/4] Update reapi_gamedll_const.inc --- reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 771dcac5..8cc322b4 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -489,8 +489,8 @@ enum GamedllFunc RG_BuyItem, /* - * Description: Called when player says a message in server chat (say and say_team) - * Params: (const pPlayer, bool:teamonly, const szText[], const pszFormat[], const pszConsoleFormat[], bool:bSenderDead, const placeName[], bool:consoleUsesPlaceName) + * Description: Called when player says a message in server chat + * Params: (const pPlayer, const szCmd[], bool:teamonly, const szText[], const pszFormat[], const pszConsoleFormat[], bool:bSenderDead, const placeName[], bool:consoleUsesPlaceName) */ RG_SendSayMessage, }; From cd94096ffa49f1fe1bab12b3cb6b630328b1a6a4 Mon Sep 17 00:00:00 2001 From: dystopm Date: Sat, 20 Dec 2025 19:34:53 -0300 Subject: [PATCH 4/4] Forgotten const --- reapi/src/hook_callback.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index b58f6e48..ea1267d1 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1786,7 +1786,7 @@ void CBasePlayer_TakeDamageImpulse(IReGameHook_CBasePlayer_TakeDamageImpulse *ch callVoidForward(RG_CBasePlayer_TakeDamageImpulse, original, indexOfEdict(pthis->pev), indexOfEdict(pAttacker->pev), flKnockbackForce, flVelModifier); } -void SendSayMessage(IReGameHook_SendSayMessage *chain, CBasePlayer *pPlayer, const char *pszCmd, BOOL teamonly, const char *pszText, const char *pszFormat, char *pszConsoleFormat, bool bSenderDead, const char *placeName, bool consoleUsesPlaceName) +void SendSayMessage(IReGameHook_SendSayMessage *chain, CBasePlayer *pPlayer, const char *pszCmd, BOOL teamonly, const char *pszText, const char *pszFormat, const char *pszConsoleFormat, bool bSenderDead, const char *placeName, bool consoleUsesPlaceName) { auto original = [chain](int _pPlayer, const char *_pszCmd, BOOL _teamonly, const char *_pszText, const char *_pszFormat, const char *_pszConsoleFormat, bool _bSenderDead, const char *_placeName, bool _consoleUsesPlaceName) {