StopSound: Seems 'Shotgun Shot' is used on CSGO.

Seems its actually used on CSGO, only difference is m_iWeaponID =>
m_weapon.
This commit is contained in:
zaCade 2018-07-22 15:19:33 +02:00
parent 86c53da79d
commit 4eeb1b004f

View File

@ -48,6 +48,9 @@ public void OnPluginStart()
g_MapMusic = new StringMap(); g_MapMusic = new StringMap();
// Detect game and hook appropriate tempent.
AddTempEntHook("Shotgun Shot", Hook_ShotgunShot);
// Ambient sounds // Ambient sounds
AddAmbientSoundHook(Hook_AmbientSound); AddAmbientSoundHook(Hook_AmbientSound);
@ -83,9 +86,6 @@ public void OnPluginStart()
} }
else // CS:S else // CS:S
{ {
// Detect game and hook appropriate tempent.
AddTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
// Weapon sounds will be caught here. // Weapon sounds will be caught here.
AddNormalSoundHook(Hook_NormalSound_CSS); AddNormalSoundHook(Hook_NormalSound_CSS);
@ -115,13 +115,16 @@ public void OnPluginEnd()
} }
} }
// Remove tempent hook
RemoveTempEntHook("Shotgun Shot", Hook_ShotgunShot);
// Remove ambient sound hook // Remove ambient sound hook
RemoveAmbientSoundHook(Hook_AmbientSound); RemoveAmbientSoundHook(Hook_AmbientSound);
// Find ReloadEffect // Find ReloadEffect
UserMsg ReloadEffect = GetUserMessageId("ReloadEffect"); UserMsg ReloadEffect = GetUserMessageId("ReloadEffect");
// Remove game-specific staff // Remove game-specific
if(GetEngineVersion() == Engine_CSGO) if(GetEngineVersion() == Engine_CSGO)
{ {
RemoveNormalSoundHook(Hook_NormalSound_CSGO); RemoveNormalSoundHook(Hook_NormalSound_CSGO);
@ -131,9 +134,6 @@ public void OnPluginEnd()
} }
else else
{ {
// Remove tempent hook
RemoveTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
RemoveNormalSoundHook(Hook_NormalSound_CSS); RemoveNormalSoundHook(Hook_NormalSound_CSS);
if(ReloadEffect != INVALID_MESSAGE_ID) 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; 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) if(!g_bStopWeaponSoundsHooked)
return Plugin_Continue; 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. // Re-broadcast to clients that still need it.
float vTemp[3]; if(GetEngineVersion() == Engine_CSGO)
TE_Start("Shotgun Shot"); {
TE_ReadVector("m_vecOrigin", vTemp); float vTemp[3];
TE_WriteVector("m_vecOrigin", vTemp); TE_Start("Shotgun Shot");
TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]")); TE_ReadVector("m_vecOrigin", vTemp);
TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]")); TE_WriteVector("m_vecOrigin", vTemp);
TE_WriteNum("m_iWeaponID", TE_ReadNum("m_iWeaponID")); TE_WriteFloat("m_vecAngles[0]", TE_ReadFloat("m_vecAngles[0]"));
TE_WriteNum("m_iMode", TE_ReadNum("m_iMode")); TE_WriteFloat("m_vecAngles[1]", TE_ReadFloat("m_vecAngles[1]"));
TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed")); TE_WriteNum("m_weapon", TE_ReadNum("m_weapon"));
TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer")); TE_WriteNum("m_iMode", TE_ReadNum("m_iMode"));
TE_WriteFloat("m_fInaccuracy", TE_ReadFloat("m_fInaccuracy")); TE_WriteNum("m_iSeed", TE_ReadNum("m_iSeed"));
TE_WriteFloat("m_fSpread", TE_ReadFloat("m_fSpread")); TE_WriteNum("m_iPlayer", TE_ReadNum("m_iPlayer"));
TE_Send(newClients, newTotal, delay); 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; return Plugin_Stop;
} }