Raised This Month: $51 Target: $400
 12% 

[CSGO] Audio being cut off at start of new round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mythikos
Junior Member
Join Date: Sep 2014
Old 05-21-2016 , 00:28   [CSGO] Audio being cut off at start of new round
Reply With Quote #1

Hey everyone. I have been working on a plugin that plays music during certain events. I encountered a problem where if the audio is playing when a new round starts, it is cut off because the round start audio for CSGO starts. I am using emitsoundany (https://forums.alliedmods.net/showthread.php?t=237045) to play the sounds in my server. Here is a snip below:

Code:
for (int i = 0; i < MAX_LENGTH; i++) {
		if (strcmp(sID, PlayerList[i][SteamID], false) == 0) {
			EmitSoundToAllAny(PlayerList[i][FilePath]);
			break;
		}
	}
I tried playing with sound channels and such but the audio always cuts off. Is there any way to give my audio higher priority over CSGO audio? Or perhaps prevent the round start music from csgo from playing?

Thanks for any and all help!
Mythikos is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 05-21-2016 , 05:30   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #2

You can prevent the round_start music from playing but that wont stop the client from ending all music/sounds from last round on round_prestart
Mitchell is offline
Mythikos
Junior Member
Join Date: Sep 2014
Old 05-21-2016 , 22:00   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #3

I tired all sorts of things. The only thing i can think of is on new round, the game is cleaning up the sound objects. I think the only way I could do this is by playing the sound in a 2d environment like from the player's ui that way the audio object isn't removed on new round.

Does anyone know how to accomplish that? Normally like the "Play" console command would do it but it doesnt seem to work in CSGO. Same with "playgamesound".

Thoughts?
Mythikos is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 05-22-2016 , 10:35   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #4

Quote:
Originally Posted by Mythikos View Post
Normally like the "Play" console command would do it but it doesnt seem to work in CSGO. Same with "playgamesound".
https://wiki.alliedmods.net/Csgo_qui...client_command
Addicted. is offline
Mythikos
Junior Member
Join Date: Sep 2014
Old 05-22-2016 , 12:44   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #5

Quote:
Originally Posted by oaaron99 View Post
That's funny, didn't even know about the quirk with the play command. I tried this and it appears it still halts the sound at the start of new rounds if the sound is playing.

I cant seem to figure out how to make sound persist through a round change :\
Mythikos is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 07-31-2016 , 11:11   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #6

Having the same problem now, did you find any fix?
__________________
We all live under the same sky but we have different horizons.
bLacK-bLooD is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 08-02-2016 , 07:53   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #7

bump
__________________
We all live under the same sky but we have different horizons.
bLacK-bLooD is offline
General Lentils
Senior Member
Join Date: Jul 2016
Old 08-02-2016 , 19:33   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #8

Quote:
Originally Posted by bLacK-bLooD View Post
bump
Maybe something like

PHP Code:
#include <sourcemod>
#include <emitsoundany>

#pragma semicolon 1

#define MUSIC "Your_music_here.mp3"

new Handle:hMusicEnabled;

public 
Plugin:myinfo =
{
    
name "Round-Start Music",
    
author "General Lentils",
    
description "Plays music at the beginning of the round",
    
version "1.0.0",
};

public 
OnPluginStart()
{
    
HookEvent("round_poststart"Event_RoundStart);
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
hMusicEnabled CreateConVar("roundmusic_enabled""1""Enable/Disable round start music"FCVAR_NOTIFYtrue0.0true1.0);
}

public 
OnMapStart()
{
    
AddFileToDownloadsTable(MUSIC);
    
PrecacheSoundAny(MUSIC);
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
1<= MaxClientsi++)
        if(
IsClientInGame(i) && GetConVarBool(hMusicEnabled))
        {
            
ClientCommand(i"playgamesound Music.StopAllMusic");
            
CreateTimer(0.5TriggerMusic, (i));
        }
}

public 
Action:TriggerMusic(Handle:timerany:client)
{
    for(new 
1<= MaxClientsi++)
    if(
IsClientInGame(i) && GetConVarBool(hMusicEnabled))
    {
        
EmitSoundToAllAny(MUSIC);
    }
    
KillTimer(timer);

I am not sure if this works, i haven't tested it by myself. But what it should do, is reload all client's sound on round start + post start, and play this music instead. If this doesn't work, play around with the timer, see if it works then. If it doesn't work at all, please inform me.

For your information: You WILL need this include file:

https://forums.alliedmods.net/showthread.php?t=237045 (thanks to PowerLord we are able to emit sounds in CS:GO)

Last edited by General Lentils; 08-02-2016 at 19:33.
General Lentils is offline
bLacK-bLooD
AlliedModders Donor
Join Date: Jun 2008
Old 08-03-2016 , 03:09   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #9

Quote:
Originally Posted by General Lentils View Post
Maybe something like

PHP Code:
#include <sourcemod>
#include <emitsoundany>

#pragma semicolon 1

#define MUSIC "Your_music_here.mp3"

new Handle:hMusicEnabled;

public 
Plugin:myinfo =
{
    
name "Round-Start Music",
    
author "General Lentils",
    
description "Plays music at the beginning of the round",
    
version "1.0.0",
};

public 
OnPluginStart()
{
    
HookEvent("round_poststart"Event_RoundStart);
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("teamplay_round_start"Event_RoundStart);
    
hMusicEnabled CreateConVar("roundmusic_enabled""1""Enable/Disable round start music"FCVAR_NOTIFYtrue0.0true1.0);
}

public 
OnMapStart()
{
    
AddFileToDownloadsTable(MUSIC);
    
PrecacheSoundAny(MUSIC);
}

public 
Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
1<= MaxClientsi++)
        if(
IsClientInGame(i) && GetConVarBool(hMusicEnabled))
        {
            
ClientCommand(i"playgamesound Music.StopAllMusic");
            
CreateTimer(0.5TriggerMusic, (i));
        }
}

public 
Action:TriggerMusic(Handle:timerany:client)
{
    for(new 
1<= MaxClientsi++)
    if(
IsClientInGame(i) && GetConVarBool(hMusicEnabled))
    {
        
EmitSoundToAllAny(MUSIC);
    }
    
KillTimer(timer);

I am not sure if this works, i haven't tested it by myself. But what it should do, is reload all client's sound on round start + post start, and play this music instead. If this doesn't work, play around with the timer, see if it works then. If it doesn't work at all, please inform me.

For your information: You WILL need this include file:

https://forums.alliedmods.net/showthread.php?t=237045 (thanks to PowerLord we are able to emit sounds in CS:GO)
I'm sorry, I believe I mislead you. We need the plugin like this:

At the end of each round, it plays a sound and it continues at round start until the song is over. Right now, it plays at the end of the round but when the round starts, it stops, even if the sound is only halfway through.

Concrete example:
- mysong.mp3 (10 seconds long)
- Round ends, song plays for 5 seconds, round starts, the song stops immediatly, instead of playing the remaining 5 seconds.
__________________
We all live under the same sky but we have different horizons.
bLacK-bLooD is offline
General Lentils
Senior Member
Join Date: Jul 2016
Old 08-03-2016 , 05:30   Re: [CSGO] Audio being cut off at start of new round
Reply With Quote #10

Quote:
Originally Posted by bLacK-bLooD View Post
I'm sorry, I believe I mislead you. We need the plugin like this:

At the end of each round, it plays a sound and it continues at round start until the song is over. Right now, it plays at the end of the round but when the round starts, it stops, even if the sound is only halfway through.

Concrete example:
- mysong.mp3 (10 seconds long)
- Round ends, song plays for 5 seconds, round starts, the song stops immediatly, instead of playing the remaining 5 seconds.

BUT: this might work:

PHP Code:
OnPluginStart()
{
    
ServerCommand("sm_cvar mp_round_restart_delay 0.11");

General Lentils is offline
Reply



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 11:57.


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