diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc index 6151043..8bc5eff 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc @@ -37,6 +37,7 @@ #define RG_CBasePlayerWeapon_DefaultDeploy RG_CBaseWeapon_DefDeploy #define RG_CBasePlayerWeapon_DefaultReload RG_CBaseWeapon_DefReload #define RG_CBasePlayerWeapon_DefaultShotgunReload RG_CBaseWeapon_DefShotgunReload + #define RG_CBasePlayer_Observer_SetMode RG_CBasePlayer_Observer_SetMod #endif /** @@ -784,6 +785,12 @@ enum GamedllFunc_CBasePlayer * Params: (const this, const reason[]) */ RG_CBasePlayer_DropIdlePlayer, + + /* + * Description: Called when a client attempt to change the observer mode. + * Params: (const this, iMode) + */ + RG_CBasePlayer_Observer_SetMode, /* * Description: Called when a client emits a "pain sound" after received damage. diff --git a/reapi/include/cssdk/dlls/regamedll_api.h b/reapi/include/cssdk/dlls/regamedll_api.h index f24e009..7924fae 100644 --- a/reapi/include/cssdk/dlls/regamedll_api.h +++ b/reapi/include/cssdk/dlls/regamedll_api.h @@ -501,6 +501,10 @@ typedef IHookChainRegistryClass IReGameHook_CBaseEntity_FireBullets3; typedef IHookChainRegistryClass IReGameHookRegistry_CBaseEntity_FireBullets3; +// CBasePlayer::Observer_SetMode hook +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_SetMode; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_SetMode; + // CBasePlayer::Pain hook typedef IHookChainClass IReGameHook_CBasePlayer_Pain; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Pain; @@ -639,6 +643,8 @@ public: virtual IReGameHookRegistry_CBaseEntity_FireBullets *CBaseEntity_FireBullets() = 0; virtual IReGameHookRegistry_CBaseEntity_FireBuckshots *CBaseEntity_FireBuckshots() = 0; virtual IReGameHookRegistry_CBaseEntity_FireBullets3 *CBaseEntity_FireBullets3() = 0; + + virtual IReGameHookRegistry_CBasePlayer_Observer_SetMode *CBasePlayer_Observer_SetMode() = 0; virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0; virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0; diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 1e0080a..5a030b2 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -1237,6 +1237,16 @@ Vector &CBaseEntity_FireBullets3(IReGameHook_CBaseEntity_FireBullets3 *chain, CB shared_rand); } +void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode) +{ + auto original = [chain](int _pthis, int _iMode) + { + chain->callNext(getPrivate(_pthis), _iMode); + }; + + callVoidForward(RG_CBasePlayer_Observer_SetMode, original, indexOfEdict(pthis->pev), iMode); +} + int g_iClientStartSpeak, g_iClientStopSpeak; void OnClientStartSpeak(size_t clientIndex) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 06eef29..4069b52 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -428,6 +428,7 @@ void CBasePlayer_RemoveSpawnProtection(IReGameHook_CBasePlayer_RemoveSpawnProtec bool CBasePlayer_HintMessageEx(IReGameHook_CBasePlayer_HintMessageEx *chain, CBasePlayer *pthis, const char *pMessage, float duration, bool bDisplayIfPlayerDead, bool bOverride); void CBasePlayer_UseEmpty(IReGameHook_CBasePlayer_UseEmpty *chain, CBasePlayer *pthis); void CBasePlayer_DropIdlePlayer(IReGameHook_CBasePlayer_DropIdlePlayer *chain, CBasePlayer *pthis, const char *reason); +void CBasePlayer_Observer_SetMode(IReGameHook_CBasePlayer_Observer_SetMode *chain, CBasePlayer *pthis, int iMode); void CBasePlayer_Pain(IReGameHook_CBasePlayer_Pain *chain, CBasePlayer *pthis, int iLastHitGroup, bool bHasArmour); void CBasePlayer_DeathSound(IReGameHook_CBasePlayer_DeathSound *chain, CBasePlayer *pthis); void CBasePlayer_JoiningThink(IReGameHook_CBasePlayer_JoiningThink *chain, CBasePlayer *pthis); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 9ab7d51..25b83c3 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -167,6 +167,9 @@ hook_t hooklist_player[] = { DLL(CBasePlayer_HintMessageEx), DLL(CBasePlayer_UseEmpty), DLL(CBasePlayer_DropIdlePlayer), + + DLL(CBasePlayer_Observer_SetMode), + DLL(CBasePlayer_Pain), DLL(CBasePlayer_DeathSound), DLL(CBasePlayer_JoiningThink), diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index d9f18db..496a230 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -192,6 +192,9 @@ enum GamedllFunc_CBasePlayer RG_CBasePlayer_HintMessageEx, RG_CBasePlayer_UseEmpty, RG_CBasePlayer_DropIdlePlayer, + + RG_CBasePlayer_Observer_SetMode, + RG_CBasePlayer_Pain, RG_CBasePlayer_DeathSound, RG_CBasePlayer_JoiningThink,