From 669d29f119faed4797cea252dca88f28c462c1b2 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sat, 23 Dec 2023 12:23:50 +0100 Subject: [PATCH] [StopSound] Owner check for CSGO and minor corrections. --- StopSound/scripting/StopSound.sp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/StopSound/scripting/StopSound.sp b/StopSound/scripting/StopSound.sp index 83c4b28b..1b046400 100644 --- a/StopSound/scripting/StopSound.sp +++ b/StopSound/scripting/StopSound.sp @@ -442,7 +442,7 @@ void ShowStopSoundsSettingsMenu(int client) menu.AddItem("1", sBuffer); Format(sBuffer, sizeof(sBuffer), "%T%T", "Map Ambient", client, g_bStopMapAmbient[client] ? "Disabled" : "Enabled", client); - menu.AddItem("1", sBuffer); + menu.AddItem("2", sBuffer); menu.ExitBackButton = true; menu.Display(client, MENU_TIME_FOREVER); @@ -630,7 +630,7 @@ public Action Hook_NormalSound_CSS(int clients[MAXPLAYERS], int &numClients, cha for(int i = 0; i < numClients; i++) { int client = clients[i]; - if(owner == client || (!g_bStopWeaponSounds[client])) + if(owner == client || !g_bStopWeaponSounds[client]) { // Keep client. clients[j] = clients[i]; @@ -658,11 +658,23 @@ public Action Hook_NormalSound_CSGO(int clients[MAXPLAYERS], int &numClients, ch return Plugin_Continue; } + int owner = -1; + if(entity > MaxClients) + { + char sClassname[64]; + if(GetEntityClassname(entity, sClassname, sizeof(sClassname))) + { + int projectile = StrContains(sClassname, "_projectile"); + if(projectile > 0 && projectile == strlen(sClassname) - strlen("_projectile")) // endswith + owner = GetEntPropEnt(entity, Prop_Send, "m_hThrower"); + } + } + int j = 0; for(int i = 0; i < numClients; i++) { int client = clients[i]; - if(!g_bStopWeaponSounds[client] && IsClientInGame(client)) + if(owner == client || !g_bStopWeaponSounds[client]) { // Keep client. clients[j] = clients[i];