Raised This Month: $32 Target: $400
 8% 

Solved Stopping sounds for all players not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 06-08-2017 , 20:24   Stopping sounds for all players not working
Reply With Quote #1

I want to stop this sound:
npc/fast_zombie/gurgle_loop1.wav
for every 300 seconds, for every player in the server.

Code:
StopSound(client, SNDCHAN_STATIC, "npc/fast_zombie/gurgle_loop1.wav");
Won't work for me.

I also tried this:
Code:
public void OnPluginStart()
{
	CreateTimer(1.0, StopSounds, _, TIMER_REPEAT);
}
 
public Action StopSounds(Handle timer)
{
	int players[MAXPLAYERS];
	int i;
	for(i = 1; i <= MaxClients; i++) 
	{
			StopSound(players[i], SNDCHAN_STATIC, "npc/fast_zombie/gurgle_loop1.wav");
			StopSound(players[i], SNDCHAN_STREAM, "npc/antlion/pain1.wav");
			StopSound(players[i], SNDCHAN_STREAM, "npc/antlion/fly1.wav");
			StopSound(players[i], SNDCHAN_STREAM, "npc/antlion/idle1.wav");				
			PrintToChatAll("Sounds automatically stopped!");
	}
}
It doesn't actually stop any sounds.

I don't know which channel is for which sound so I messed with stream and static but nothing is getting stopped.

Last edited by Ethorbit; 06-09-2017 at 22:31.
Ethorbit is offline
Walgrim
AlliedModders Donor
Join Date: Dec 2015
Location: France
Old 06-09-2017 , 04:40   Re: Stopping sounds for all players not working
Reply With Quote #2

Hoi,
Try this
PHP Code:
public void OnPluginStart()
{
    
CreateTimer(1.0StopSounds_TIMER_REPEAT);
}

public 
Action StopSounds(Handle timer)
{
    for(new 
i=1;i<=MaxClients;i++)
    {
            
StopSound(iSNDCHAN_AUTO"npc/fast_zombie/gurgle_loop1.wav");
            
StopSound(iSNDCHAN_AUTO"npc/antlion/pain1.wav");
            
StopSound(iSNDCHAN_AUTO"npc/antlion/fly1.wav");
            
StopSound(iSNDCHAN_AUTO"npc/antlion/idle1.wav");
            
PrintToChatAll("Sounds automatically stopped!");
    }

Well if you want it for every 300 seconds just set the timer at 300.0 and use OnMapStart maybe
__________________

Last edited by Walgrim; 06-09-2017 at 04:42.
Walgrim is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 06-09-2017 , 05:27   Re: Stopping sounds for all players not working
Reply With Quote #3

check your error log
probably have errors about invalid client index ;)
8guawong is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 06-09-2017 , 17:12   Re: Stopping sounds for all players not working
Reply With Quote #4

Quote:
Originally Posted by Walgrim View Post
Hoi,
Try this
Thanks! I apparently had #pragma newdecls required so that's why my code was so bad, it kept telling me to use new declarations and I was confused at that.

However, even trying the
PHP Code:
public void OnMapStart()
{
    
CreateTimer(1.0StopSounds_TIMER_REPEAT);

Nothing is getting stopped, I have this antlion in my map which is set to make a lot of pain sounds, but it is still heard even with this script running.

I'm trying 1 second for now so that way I'll know if the script works or not.


Not sure if the sound name is wrong or something, but here's what it looks like in hammer:
http://imgur.com/a/8YMPA

Last edited by Ethorbit; 06-09-2017 at 17:14.
Ethorbit is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 06-09-2017 , 18:17   Re: Stopping sounds for all players not working
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
check your error log
probably have errors about invalid client index ;)
Nope.
Checked
F:\Server\hl2mp server\hl2mp\addons\sourcemod\logs and
F:\Server\hl2mp server\hl2mp\logs

Server console
Ingame console
0 errors

Last edited by Ethorbit; 06-09-2017 at 18:18.
Ethorbit is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-09-2017 , 18:30   Re: Stopping sounds for all players not working
Reply With Quote #6

PHP Code:
ClientCommand(client"playgamesound Music.StopAllExceptMusic"); 
Maybe?
headline is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 06-09-2017 , 18:49   Re: Stopping sounds for all players not working
Reply With Quote #7

Quote:
Originally Posted by Headline View Post
PHP Code:
ClientCommand(client"playgamesound Music.StopAllExceptMusic"); 
Maybe?
About that error thing earlier, I just used that command and got:
L 06/09/2017 - 15:47:31: [SM] Exception reported: Client 2 is not connected
when I was all alone
adding a bot made the server lag and for 5 seconds and then did this:
L 06/09/2017 - 15:47:31: [SM] Exception reported: Client 3 is not connected
The server continued to function fine, but the sounds never stopped.

PHP Code:
#include <sdktools>

public void OnMapStart()
{
    
CreateTimer(1.0StopSounds_TIMER_REPEAT);
}

public 
Action StopSounds(Handle timer)
{
    for(new 
i=1;i<=MaxClients;i++)
    {
    
ClientCommand(i"playgamesound Music.StopAllExceptMusic");  
            
PrintToChatAll("Sounds automatically stopped!");
    }


Last edited by Ethorbit; 06-09-2017 at 18:50.
Ethorbit is offline
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 06-09-2017 , 18:59   Re: Stopping sounds for all players not working
Reply With Quote #8

Okay, so I implemented a check, there's no errors now, nor does the server lag when a bot connects, but the sounds are not being stopped still.
PHP Code:
#include <sdktools>

public void OnMapStart()
{
    
CreateTimer(1.0StopSounds_TIMER_REPEAT);
}

public 
Action StopSounds(Handle timer)
{
    for(new 
i=1;i<=MaxClients;i++)
    {
    if(
IsClientInGame(i) && !IsFakeClient(i)) { 
    
ClientCommand(i"playgamesound Music.StopAllExceptMusic");  
            
PrintToChatAll("Sounds automatically stopped!");
        }
        else
        {
        return
        }
    }

It seems that I found a workaround for the sound loops outside of sourcemod. I don't need the fix anymore, I think this script works on other games, but I've been creating it for Half-Life 2: Deathmatch for anyone wondering.

You're welcome to find a fix, I probably won't be using it.

Last edited by Ethorbit; 06-09-2017 at 19:43.
Ethorbit is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode