View Single Post
Uncle Jessie
Member
Join Date: May 2016
Location: Mind Prison
Old 03-11-2017 , 08: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