StopSound: Use new OnBroadcastSound forward from CSSFixes
This commit is contained in:
parent
c993d05129
commit
e1bab3c5b8
@ -7,8 +7,9 @@
|
|||||||
#include <cstrike>
|
#include <cstrike>
|
||||||
#include <clientprefs>
|
#include <clientprefs>
|
||||||
#include <multicolors>
|
#include <multicolors>
|
||||||
|
#include <CSSFixes>
|
||||||
|
|
||||||
#define PLUGIN_VERSION "2.1.0"
|
#define PLUGIN_VERSION "3.0"
|
||||||
#define MAX_MAPMUSIC_ENTITIES 2048
|
#define MAX_MAPMUSIC_ENTITIES 2048
|
||||||
|
|
||||||
bool g_bStopWeaponSounds[MAXPLAYERS+1] = { false, ... };
|
bool g_bStopWeaponSounds[MAXPLAYERS+1] = { false, ... };
|
||||||
@ -53,17 +54,15 @@ public void OnPluginStart()
|
|||||||
// Detect game and hook appropriate tempent.
|
// Detect game and hook appropriate tempent.
|
||||||
AddTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
|
AddTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
|
||||||
|
|
||||||
// Ambient sounds
|
|
||||||
//AddAmbientSoundHook(Hook_AmbientSound);
|
|
||||||
|
|
||||||
// Map music will be caught here
|
// Map music will be caught here
|
||||||
HookEvent("round_end", Event_RoundEnd);
|
HookEvent("round_end", Event_RoundEnd);
|
||||||
HookEvent("player_spawn", Event_PlayerSpawn);
|
HookEvent("player_spawn", Event_PlayerSpawn);
|
||||||
|
|
||||||
CreateConVar("sm_stopsound_version", PLUGIN_VERSION, "Toggle Weapon Sounds", FCVAR_NOTIFY|FCVAR_DONTRECORD|FCVAR_REPLICATED);
|
CreateConVar("sm_stopsound_version", PLUGIN_VERSION, "Toggle Weapon Sounds", FCVAR_NOTIFY|FCVAR_DONTRECORD|FCVAR_REPLICATED);
|
||||||
RegConsoleCmd("sm_stopsound", Command_StopSound, "Toggle hearing weapon sounds");
|
RegConsoleCmd("sm_stopsound", Command_StopSound, "Toggle hearing weapon sounds");
|
||||||
//RegConsoleCmd("sm_stopmusic", Command_StopMusic, "Toggle hearing map music");
|
RegConsoleCmd("sm_sound", Command_StopSound, "Toggle hearing weapon sounds");
|
||||||
//RegConsoleCmd("sm_music", Command_StopMusic, "Toggle hearing map music");
|
RegConsoleCmd("sm_stopmusic", Command_StopMusic, "Toggle hearing map music");
|
||||||
|
RegConsoleCmd("sm_music", Command_StopMusic, "Toggle hearing map music");
|
||||||
|
|
||||||
// Cookies
|
// Cookies
|
||||||
g_hCookieStopSound = RegClientCookie("weaponsound_blocked", "Are weapon sounds enabled", CookieAccess_Protected);
|
g_hCookieStopSound = RegClientCookie("weaponsound_blocked", "Are weapon sounds enabled", CookieAccess_Protected);
|
||||||
@ -119,9 +118,6 @@ public void OnPluginEnd()
|
|||||||
// Remove tempent hook
|
// Remove tempent hook
|
||||||
RemoveTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
|
RemoveTempEntHook("Shotgun Shot", CSS_Hook_ShotgunShot);
|
||||||
|
|
||||||
// Remove ambient sound hook
|
|
||||||
//RemoveAmbientSoundHook(Hook_AmbientSound);
|
|
||||||
|
|
||||||
// Find ReloadEffect
|
// Find ReloadEffect
|
||||||
UserMsg ReloadEffect = GetUserMessageId("ReloadEffect");
|
UserMsg ReloadEffect = GetUserMessageId("ReloadEffect");
|
||||||
|
|
||||||
@ -235,7 +231,7 @@ public void OnClientCookiesCached(int client)
|
|||||||
// Map Music cookie
|
// Map Music cookie
|
||||||
GetClientCookie(client, g_hCookieStopMapMusic, sBuffer, sizeof(sBuffer));
|
GetClientCookie(client, g_hCookieStopMapMusic, sBuffer, sizeof(sBuffer));
|
||||||
|
|
||||||
if(sBuffer[0] != '\0' && false)
|
if(sBuffer[0] != '\0')
|
||||||
{
|
{
|
||||||
g_bStopMapMusic[client] = true;
|
g_bStopMapMusic[client] = true;
|
||||||
g_bStopMapMusicHooked = true;
|
g_bStopMapMusicHooked = true;
|
||||||
@ -643,11 +639,8 @@ public void OnReloadEffect(DataPack pack)
|
|||||||
EndMessage();
|
EndMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Hook_AmbientSound(char sample[PLATFORM_MAX_PATH], int &entity, float &volume, int &level, int &pitch, float pos[3], int &flags, float &delay)
|
public Action OnBroadcastSound(int entity, char sample[PLATFORM_MAX_PATH], int clients[MAXPLAYERS], int &numClients)
|
||||||
{
|
{
|
||||||
if(!g_bStopMapMusicHooked)
|
|
||||||
return Plugin_Continue;
|
|
||||||
|
|
||||||
// Music
|
// Music
|
||||||
if(sample[0] != '#')
|
if(sample[0] != '#')
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
@ -657,26 +650,25 @@ public Action Hook_AmbientSound(char sample[PLATFORM_MAX_PATH], int &entity, flo
|
|||||||
|
|
||||||
g_MapMusic.SetString(sEntity, sample, true);
|
g_MapMusic.SetString(sEntity, sample, true);
|
||||||
|
|
||||||
|
if(!g_bStopMapMusicHooked)
|
||||||
|
return Plugin_Continue;
|
||||||
|
|
||||||
// Check which clients need to be excluded.
|
// Check which clients need to be excluded.
|
||||||
int[] newClients = new int[MaxClients];
|
int newClients = 0;
|
||||||
int newTotal = 0;
|
for(int i = 0; i < numClients; i++)
|
||||||
bool bEmitNew = false;
|
|
||||||
|
|
||||||
for(int i = 1; i <= MaxClients; i++)
|
|
||||||
{
|
{
|
||||||
if(!IsClientInGame(i))
|
int client = clients[i];
|
||||||
continue;
|
if(!g_bStopMapMusic[client])
|
||||||
|
{
|
||||||
if(!g_bStopMapMusic[i])
|
clients[numClients] = clients[i];
|
||||||
newClients[newTotal++] = i;
|
newClients++;
|
||||||
else
|
}
|
||||||
bEmitNew = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bEmitNew && newTotal)
|
if(newClients != numClients)
|
||||||
{
|
{
|
||||||
EmitSound(newClients, newTotal, sample, entity, SNDCHAN_STATIC, level, flags, volume, pitch);
|
numClients = newClients;
|
||||||
return Plugin_Handled;
|
return Plugin_Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
forward void OnRunThinkFunctions(bool simulating);
|
forward void OnRunThinkFunctions(bool simulating);
|
||||||
forward void OnRunThinkFunctionsPost(bool simulating);
|
forward void OnRunThinkFunctionsPost(bool simulating);
|
||||||
|
forward Action OnBroadcastSound(int entity, char sample[PLATFORM_MAX_PATH], int clients[MAXPLAYERS], int &numClients);
|
||||||
|
|
||||||
public Extension __ext_CSSFixes =
|
public Extension __ext_CSSFixes =
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user