@@ -95,6 +95,7 @@ SH_DECL_MANUALHOOK3_void(DropWeapon, 0, 0, 0, CBasePlayerWeapon*, Vector*, Vecto
9595SH_DECL_HOOK1_void (IServer, SetGameSpawnGroupMgr, SH_NOATTRIB , 0 , IGameSpawnGroupMgr*);
9696SH_DECL_HOOK2_void (CEntitySystem, Spawn, SH_NOATTRIB , 0 , int , const EntitySpawnInfo_t*);
9797SH_DECL_MANUALHOOK3_void (Teleport, 0 , 0 , 0 , const Vector*, const QAngle*, const Vector*);
98+ SH_DECL_HOOK1 (CServerSideClient, ProcessVoiceData, SH_NOATTRIB , 0 , bool , const CCLCMsg_VoiceData_t&);
9899
99100CS2Fixes g_CS2Fixes;
100101IGameEventSystem* g_gameEventSystem = nullptr ;
@@ -117,6 +118,7 @@ int g_iWeaponServiceDropWeaponId = -1;
117118int g_iSetGameSpawnGroupMgrId = -1 ;
118119int g_iSpawnId = -1 ;
119120int g_iTeleportId = -1 ;
121+ int g_iProcessVoiceDataId = -1 ;
120122
121123double g_flUniversalTime = 0.0 ;
122124float g_flLastTickedTime = 0 .0f ;
@@ -322,6 +324,9 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool
322324 auto pCEntitySystemVTable = (CEntitySystem*)modules::server->FindVirtualTable (" CGameEntitySystem" );
323325 g_iSpawnId = SH_ADD_DVPHOOK (CEntitySystem, Spawn, pCEntitySystemVTable, SH_MEMBER (this , &CS2Fixes::Hook_SpawnPost), true );
324326
327+ auto pCServerSideClientVTable = (CServerSideClient*)modules::engine->FindVirtualTable (" CServerSideClient" );
328+ g_iProcessVoiceDataId = SH_ADD_DVPHOOK (CServerSideClient, ProcessVoiceData, pCServerSideClientVTable, SH_MEMBER (this , &CS2Fixes::Hook_ProcessVoiceData), false );
329+
325330 if (!bRequiredInitLoaded)
326331 {
327332 snprintf (error, maxlen, " One or more address lookups, patches or detours failed, please refer to startup logs for more information" );
@@ -428,6 +433,7 @@ bool CS2Fixes::Unload(char* error, size_t maxlen)
428433 SH_REMOVE_HOOK_ID (g_iCTriggerGravityEndTouchId);
429434 SH_REMOVE_HOOK_ID (g_iSpawnId);
430435 SH_REMOVE_HOOK_ID (g_iTeleportId);
436+ SH_REMOVE_HOOK_ID (g_iProcessVoiceDataId);
431437
432438 if (g_iSetGameSpawnGroupMgrId != -1 )
433439 SH_REMOVE_HOOK_ID (g_iSetGameSpawnGroupMgrId);
@@ -1208,6 +1214,27 @@ void CS2Fixes::Hook_CCSPlayerPawn_Teleport(const Vector* pPosition, const QAngle
12081214 RETURN_META (MRES_HANDLED );
12091215}
12101216
1217+ bool CS2Fixes::Hook_ProcessVoiceData (const CCLCMsg_VoiceData_t& msg)
1218+ {
1219+ CServerSideClient* client = META_IFACEPTR (CServerSideClient);
1220+
1221+ if (!client)
1222+ RETURN_META_VALUE (MRES_IGNORED , true );
1223+
1224+ ZEPlayer* pPlayer = g_playerManager->GetPlayer (client->GetPlayerSlot ());
1225+
1226+ if (!pPlayer)
1227+ RETURN_META_VALUE (MRES_IGNORED , true );
1228+
1229+ // logic following sourcemod's implementation of OnClientSpeaking
1230+ if (auto timer = pPlayer->GetVoiceTimer ().lock ())
1231+ timer->Cancel ();
1232+
1233+ pPlayer->SetVoiceTimer (CTimer::Create (0 .3f , TIMERFLAG_NONE , [](){ return -1 .0f ; }));
1234+
1235+ RETURN_META_VALUE (MRES_IGNORED , true );
1236+ }
1237+
12111238void * CS2Fixes::OnMetamodQuery (const char * iface, int * ret)
12121239{
12131240 if (V_strcmp (iface, CS2FIXES_INTERFACE ))
0 commit comments