Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #4 #5

Merged
merged 2 commits into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions addons/sourcemod/scripting/StopSound.sp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Plugin myinfo =
name = "Toggle Game Sounds",
author = "GoD-Tony, edit by Obus + BotoX, Oleg Tsvetkov",
description = "Allows clients to stop hearing weapon sounds and map music",
version = "3.1.2",
version = "3.1.3",
url = "http://www.sourcemod.net/"
};

Expand Down Expand Up @@ -415,7 +415,7 @@ public Action Hook_ShotgunShot(const char[] te_name, const int[] Players, int nu

for(int i = 0; i < numClients; i++)
{
if(!g_bStopWeaponSounds[Players[i]])
if(Players[i] > 0 && Players[i] <= MaxClients && IsClientInGame(Players[i]) && !g_bStopWeaponSounds[Players[i]])
{
newClients[newTotal++] = Players[i];
}
Expand Down Expand Up @@ -464,7 +464,7 @@ public Action Hook_ReloadEffect_CSS(UserMsg msg_id, BfRead msg, const int[] play
for(int i = 0; i < playersNum; i++)
{
int client_ = players[i];
if(IsClientInGame(client_) && !g_bStopWeaponSounds[client_])
if(client_ > 0 && client_ <= MaxClients && IsClientInGame(client_) && !g_bStopWeaponSounds[client_])
{
newClients[newTotal++] = client_;
}
Expand Down Expand Up @@ -499,6 +499,13 @@ public void OnReloadEffect(DataPack pack)
{
pack.Reset();
int client = pack.ReadCell();

if(client <= 0 || client > MaxClients || !IsClientInGame(client))
{
delete pack;
return;
}

int newTotal = pack.ReadCell();

int[] players = new int[newTotal];
Expand All @@ -507,14 +514,19 @@ public void OnReloadEffect(DataPack pack)
for(int i = 0; i < newTotal; i++)
{
int client_ = pack.ReadCell();
if(IsClientInGame(client_))
// In case of invalid client, skip it.
if(client_ > 0 && client_ <= MaxClients && IsClientInGame(client_))
{
players[playersNum++] = client_;
}
}

CloseHandle(pack);

// All clients were excluded and there is no need to broadcast.
if(playersNum == 0)
return;

Handle ReloadEffect = StartMessage("ReloadEffect", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)
{
Expand Down
Loading