Raised This Month: $30 Target: $400
 7% 

[L4D2] How to stop music?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Uncle Jessie
Member
Join Date: May 2016
Location: Prison
Old 03-11-2017 , 09:26   [L4D2] How to stop music?
Reply With Quote #1

How to stop music in L4D2? It's not working.

PHP Code:
new const String:g_Music[2][] =
{
    
"music/witch",
    
"music/tank"
};


public 
Action:MusicSoundHook(clients[64], &numClientsString:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags

    if (
i_Music == 1) { // Music sounds
        
for (new 0sizeof(g_Music); i++) {
            if (
StrContains(sampleg_Music[i], false) > -1) {
                
volume 0.0;
                return 
Plugin_Changed;
            }
        }
    }

    return 
Plugin_Continue;


Last edited by Uncle Jessie; 03-11-2017 at 09:28.
Uncle Jessie is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 09:40   Re: [L4D2] How to stop music?
Reply With Quote #2

Quote:
Originally Posted by Uncle Jessie View Post
How to stop music in L4D2? It's not working.
-snip-
StopSound(). If you don't know the sound name, you can add a sound hook to find out what the directory is when it plays.

Last edited by Weetabix; 03-11-2017 at 09:41.
Weetabix is offline
Uncle Jessie
Member
Join Date: May 2016
Location: Prison
Old 03-11-2017 , 09:44   Re: [L4D2] How to stop music?
Reply With Quote #3

Quote:
Originally Posted by Weetabix View Post
StopSound(). If you don't know the sound name, you can add a sound hook to find out what the directory is when it plays.

It's not working too.
PHP Code:
public OnMapStart()
{
    
CheckSoundPreCache("music/tank/midnighttank.wav");
    
CheckSoundPreCache("music/tank/onebadtank.wav");
    
CheckSoundPreCache("music/tank/taank.wav");
    
CheckSoundPreCache("music/tank/tank.wav");
}

stock CheckSoundPreCache(const String:Soundfile[])
{
    
PrecacheSound(Soundfiletrue);
    
PrintToServer("Precaching Sound:%s",Soundfile);
}


public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientConnected(i) && IsClientInGame(i))
        {
            
StopSound(iSNDCHAN_STATIC"music/tank/midnighttank.wav");
            
StopSound(iSNDCHAN_STATIC"music/tank/onebadtank.wav");
            
StopSound(iSNDCHAN_STATIC"music/tank/taank.wav");
            
StopSound(iSNDCHAN_STATIC"music/tank/tank.wav");
            
TimerStopSound[i] = CreateTimer(1.0/10Timer_StopSoundiTIMER_REPEAT);
            
TimerStopTimer[i] = CreateTimer(7.0Timer_StopTimeri);
        }
    }
}

public 
Action:Timer_StopSound(Handle:timerany:client)
{
    if (
TimerStopSound[client] != INVALID_HANDLE)
    {
            
StopSound(clientSNDCHAN_STATIC"music/tank/midnighttank.wav");
            
StopSound(clientSNDCHAN_STATIC"music/tank/onebadtank.wav");
            
StopSound(clientSNDCHAN_STATIC"music/tank/taank.wav");
            
StopSound(clientSNDCHAN_STATIC"music/tank/tank.wav");
            
PrintToChatAll("Stopping MUSIC sound");
    }
}

public 
Action:Timer_StopTimer(Handle:timerany:client)
{
    if (
TimerStopSound[client] != INVALID_HANDLE)
    {
        
KillTimer(TimerStopSound[client]);
        
TimerStopSound[client] = INVALID_HANDLE;
        
PrintToChatAll("TimerStopMusic finished.");
    }

Uncle Jessie is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 03-11-2017 , 09:52   Re: [L4D2] How to stop music?
Reply With Quote #4

Try SNDCHAN_AUTO instead
__________________
Benoist3012 is offline
Uncle Jessie
Member
Join Date: May 2016
Location: Prison
Old 03-11-2017 , 11:27   Re: [L4D2] How to stop music?
Reply With Quote #5

Quote:
Originally Posted by Benoist3012 View Post
Try SNDCHAN_AUTO instead
Nothing helps, this music still plays.
All other sounds are stopped, but not from the music folder

Last edited by Uncle Jessie; 03-11-2017 at 11:42.
Uncle Jessie is offline
sdz
Senior Member
Join Date: Feb 2012
Location: United States
Old 03-11-2017 , 20:53   Re: [L4D2] How to stop music?
Reply With Quote #6

Pretty sure you can't do this since it's a clientsided sound.
Same with footsteps
sdz is offline
Uncle Jessie
Member
Join Date: May 2016
Location: Prison
Old 03-11-2017 , 22:06   Re: [L4D2] How to stop music?
Reply With Quote #7

Quote:
Originally Posted by EasSidezz View Post
Pretty sure you can't do this since it's a clientsided sound.
Same with footsteps
The solution is sm_cvar music_manager 0, this is exactly what I needed.

Last edited by Uncle Jessie; 03-11-2017 at 22:07.
Uncle Jessie is offline
Edison1318
Senior Member
Join Date: Nov 2015
Location: Peaceful place of the in
Old 03-12-2017 , 00:37   Re: [L4D2] How to stop music?
Reply With Quote #8

I have this same problem too, there's another way that is type in the console music_dynamic_stop_playing in some music event it will eventually stop, but certain musics it cannot be stop somehow.
__________________
EdisonGar

Last edited by Edison1318; 03-12-2017 at 00:38.
Edison1318 is offline
Send a message via Skype™ to Edison1318
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 03-12-2017 , 10:43   Re: [L4D2] How to stop music?
Reply With Quote #9

Quote:
Originally Posted by Edison1318 View Post
music_dynamic_stop_playing
Sadly its a protected cvar/cmd now. Thanks Valve.
Also, HOW IS "clear" AN EXPLOITABLE COMMAND, VALVE?!!?
Timocop 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 10:47.


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