From 4eeb1b004fe44d83d42816409f314d56dc222960 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sun, 22 Jul 2018 15:19:33 +0200 Subject: [PATCH] StopSound: Seems 'Shotgun Shot' is used on CSGO. Seems its actually used on CSGO, only difference is m_iWeaponID => m_weapon. --- StopSound/scripting/StopSound.sp | 61 +++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/StopSound/scripting/StopSound.sp b/StopSound/scripting/StopSound.sp index b4c449ae..f98102c1 100644 --- a/StopSound/scripting/StopSound.sp +++ b/StopSound/scripting/StopSound.sp @@ -48,6 +48,9 @@ public void OnPluginStart() g_MapMusic = new StringMap(); + // Detect game and hook appropriate tempent. + AddTempEntHook("Shotgun Shot", Hook_ShotgunShot); + // Ambient sounds AddAmbientSoundHook(Hook_AmbientSound); @@ -83,9 +86,6 @@ public void OnPluginStart() } else // CS:S { - // Detect game and hook appropriate tempent. - AddTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot); - // Weapon sounds will be caught here. AddNormalSoundHook(Hook_NormalSound_CSS); @@ -115,13 +115,16 @@ public void OnPluginEnd() } } + // Remove tempent hook + RemoveTempEntHook("Shotgun Shot", Hook_ShotgunShot); + // Remove ambient sound hook RemoveAmbientSoundHook(Hook_AmbientSound); // Find ReloadEffect UserMsg ReloadEffect = GetUserMessageId("ReloadEffect"); - // Remove game-specific staff + // Remove game-specific if(GetEngineVersion() == Engine_CSGO) { RemoveNormalSoundHook(Hook_NormalSound_CSGO); @@ -131,9 +134,6 @@ public void OnPluginEnd() } else { - // Remove tempent hook - RemoveTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot); - RemoveNormalSoundHook(Hook_NormalSound_CSS); if(ReloadEffect != INVALID_MESSAGE_ID) @@ -456,7 +456,7 @@ public Action Hook_NormalSound_CSGO(int clients[MAXPLAYERS], int &numClients, ch return (numClients > 0) ? Plugin_Changed : Plugin_Stop; } -public Action CSS_Hook_ShotgunShot(const char[] te_name, const int[] Players, int numClients, float delay) +public Action Hook_ShotgunShot(const char[] te_name, const int[] Players, int numClients, float delay) { if(!g_bStopWeaponSoundsHooked) return Plugin_Continue; @@ -485,19 +485,38 @@ public Action CSS_Hook_ShotgunShot(const char[] te_name, const int[] Players, in } // Re-broadcast to clients that still need it. - float vTemp[3]; - TE_Start("Shotgun Shot"); - TE_ReadVector("m_vecOrigin", vTemp); - TE_WriteVector("m_vecOrigin", vTemp); - TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]")); - TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]")); - TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID")); - TE_WriteNum("m_iMode", TE_ReadNum("m_iMode")); - TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed")); - TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer")); - TE_WriteFloat("m_fInaccuracy", TE_ReadFloat("m_fInaccuracy")); - TE_WriteFloat("m_fSpread", TE_ReadFloat("m_fSpread")); - TE_Send(newClients, newTotal, delay); + if(GetEngineVersion() == Engine_CSGO) + { + float vTemp[3]; + TE_Start("Shotgun Shot"); + TE_ReadVector("m_vecOrigin", vTemp); + TE_WriteVector("m_vecOrigin", vTemp); + TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]")); + TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]")); + TE_WriteNum("m_weapon", TE_ReadNum("m_weapon")); + TE_WriteNum("m_iMode", TE_ReadNum("m_iMode")); + TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed")); + TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer")); + TE_WriteFloat("m_fInaccuracy", TE_ReadFloat("m_fInaccuracy")); + TE_WriteFloat("m_fSpread", TE_ReadFloat("m_fSpread")); + TE_Send(newClients, newTotal, delay); + } + else + { + float vTemp[3]; + TE_Start("Shotgun Shot"); + TE_ReadVector("m_vecOrigin", vTemp); + TE_WriteVector("m_vecOrigin", vTemp); + TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]")); + TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]")); + TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID")); + TE_WriteNum("m_iMode", TE_ReadNum("m_iMode")); + TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed")); + TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer")); + TE_WriteFloat("m_fInaccuracy", TE_ReadFloat("m_fInaccuracy")); + TE_WriteFloat("m_fSpread", TE_ReadFloat("m_fSpread")); + TE_Send(newClients, newTotal, delay); + } return Plugin_Stop; }