AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [L4D2] How to stop music? (https://forums.alliedmods.net/showthread.php?t=294916)

Uncle Jessie 03-11-2017 08:26

[L4D2] How to stop music?
 
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;



Weetabix 03-11-2017 08:40

Re: [L4D2] How to stop music?
 
Quote:

Originally Posted by Uncle Jessie (Post 2502643)
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.

Uncle Jessie 03-11-2017 08:44

Re: [L4D2] How to stop music?
 
Quote:

Originally Posted by Weetabix (Post 2502649)
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.");
    }



Benoist3012 03-11-2017 08:52

Re: [L4D2] How to stop music?
 
Try SNDCHAN_AUTO instead

Uncle Jessie 03-11-2017 10:27

Re: [L4D2] How to stop music?
 
Quote:

Originally Posted by Benoist3012 (Post 2502657)
Try SNDCHAN_AUTO instead

Nothing helps, this music still plays.
All other sounds are stopped, but not from the music folder

sdz 03-11-2017 19:53

Re: [L4D2] How to stop music?
 
Pretty sure you can't do this since it's a clientsided sound.
Same with footsteps

Uncle Jessie 03-11-2017 21:06

Re: [L4D2] How to stop music?
 
Quote:

Originally Posted by EasSidezz (Post 2502843)
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.

Edison1318 03-11-2017 23:37

Re: [L4D2] How to stop music?
 
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.

Timocop 03-12-2017 09:43

Re: [L4D2] How to stop music?
 
Quote:

Originally Posted by Edison1318 (Post 2502868)
music_dynamic_stop_playing

Sadly its a protected cvar/cmd now. Thanks Valve.
Also, HOW IS "clear" AN EXPLOITABLE COMMAND, VALVE?!!?


All times are GMT -4. The time now is 02:43.

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