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

[REQUEST] Music Plugin Fix (CSGO)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
noahspaghetti
Member
Join Date: Mar 2020
Old 04-03-2020 , 06:23   [REQUEST] Music Plugin Fix (CSGO)
Reply With Quote #1

I took a script from General Lentils that plays music at the start of the round. It works no doubt, except the music gets interrupted when another sound plays, such as quake sounds.

PHP Code:
#include <sourcemod>

#include <emitsoundany>



#pragma semicolon 1



#define MUSIC "sound/round_music/lean_on.mp3"

#define PLAY "round_music/lean_on.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(PLAY);

}



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(PLAY);

    }

    
KillTimer(timer);


Here is the code, is there any way someone can make it to where the music doesn't get interrupted when other sounds overlap the music? Thanks!

Last edited by noahspaghetti; 04-03-2020 at 08:31.
noahspaghetti is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-03-2020 , 07:14   Re: [REQUEST] Music Fix
Reply With Quote #2

**edit
what this mean ?
https://forums.alliedmods.net/showthread.php?t=237045
Quote:
Originally Posted by Powerlord View Post
As of a 2018 CS:GO update, this include is no longer necessary



SNDCHAN_AUTO is now default.
Code:
EmitSoundToAllAny(PLAY, _, SNDCHAN_AUTO);
And you have these options.
PHP Code:
/**
 * Sound channels.
 */
enum
{
    
SNDCHAN_REPLACE = -1,       /**< Unknown */
    
SNDCHAN_AUTO 0,           /**< Auto */
    
SNDCHAN_WEAPON 1,         /**< Weapons */
    
SNDCHAN_VOICE 2,          /**< Voices */
    
SNDCHAN_ITEM 3,           /**< Items */
    
SNDCHAN_BODY 4,           /**< Player? */
    
SNDCHAN_STREAM 5,         /**< "Stream channel from the static or dynamic area" */
    
SNDCHAN_STATIC 6,         /**< "Stream channel from the static area" */
    
SNDCHAN_VOICE_BASE 7,     /**< "Channel for network voice data" */
    
SNDCHAN_USER_BASE 135     /**< Anything >= this is allocated to game code */
}; 

Don't know your plugins and which channels those plugins play sounds.

*edit
CSGO
I'm not sure, is there 'symbol' to fix this problem.
like:
Code:
+campaign\web\web_valeria_guardian_mid_mission_18.wav

Last edited by Bacardi; 04-03-2020 at 07:53.
Bacardi is offline
noahspaghetti
Member
Join Date: Mar 2020
Old 04-03-2020 , 08:01   Re: [REQUEST] Music Fix
Reply With Quote #3

The only plugins I have that use sound is currently:

https://forums.alliedmods.net/showthread.php?t=287879

&

https://forums.alliedmods.net/showthread.php?t=58548 (Not sure if this is the link where I downloaded it from)

&

https://forums.alliedmods.net/showthread.php?t=318782


Not sure if these are of any help to you, but those plugins are the only ones that play sounds. Whenever one of these sounds come on it'll interrupt the music and the music won't play anymore after that. It's even worse since whenever a player shoots a paintball, it interrupts it as well.

I'll go ahead and try adding "EmitSoundToAllAny(PLAY, _, SNDCHAN_AUTO);"

Last edited by noahspaghetti; 04-03-2020 at 08:01.
noahspaghetti is offline
noahspaghetti
Member
Join Date: Mar 2020
Old 04-03-2020 , 08:07   Re: [REQUEST] Music Fix
Reply With Quote #4

Quote:
Originally Posted by Bacardi View Post

EmitSoundsAny is used for music plugins such as this, I assume valve did something to where it was not necessary anymore, but this plugin was made around EmitSoundsAny. It may not be necessary for other plugins but for this one yes, as it was made around the time when it was necessary.

Last edited by noahspaghetti; 04-03-2020 at 08:07.
noahspaghetti is offline
noahspaghetti
Member
Join Date: Mar 2020
Old 04-03-2020 , 08:31   Re: [REQUEST] Music Fix
Reply With Quote #5

Code:
EmitSoundToAllAny(PLAY, _, SNDCHAN_AUTO);
And you have these options.[/QUOTE]

Didn't work.
noahspaghetti is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-03-2020 , 10:27   Re: [REQUEST] Music Plugin Fix (CSGO)
Reply With Quote #6

I didn't change much in code.
But try, does this have anything difference.

PHP Code:



#define MUSIC "sound/round_music/lean_on.mp3"
#define PLAY "*round_music/lean_on.mp3" // in CSGO, asterix * prevent play sound twice or more.


#include <sdktools>

ConVar hMusicEnabled;

public 
Plugin myinfo =
{
    
name "Round-Start Music",
    
author "",
    
description "Plays music at the beginning of the round",
    
version "0.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"_true0.0true1.0);
}

public 
void OnConfigsExecuted()
{
    
AddFileToDownloadsTable(MUSIC);
    
PrecacheSound(PLAY);
}

public 
void Event_RoundStartEvent event, const char[] namebool dontBroadcast)
{
    if(!
hMusicEnabled.BoolValue) return;

    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || IsFakeClient(i)) continue;

        
ClientCommand(i"playgamesound Music.StopAllMusic");
    }


    
CreateTimer(0.5TriggerMusic);
}

public 
Action TriggerMusic(Handle timer)
{
    
//                                volume 0.0 - 1.0
    
EmitSoundToAll(PLAY_SNDCHAN_AUTO__0.2);

__________________
Do not Private Message @me

Last edited by Bacardi; 04-03-2020 at 10:35.
Bacardi is offline
noahspaghetti
Member
Join Date: Mar 2020
Old 04-03-2020 , 12:56   Re: [REQUEST] Music Plugin Fix (CSGO)
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
I didn't change much in code.
But try, does this have anything different.
It didn't work Bacardi, thanks for trying though. I wish there was something like Kento's Touchdown plugin where he created a BGM list that played automatically.
noahspaghetti is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 04-03-2020 , 13:13   Re: [REQUEST] Music Plugin Fix (CSGO)
Reply With Quote #8

ok. I haven't play much with sounds channel.

Does it make difference if we use any other value in channel
Code:
EmitSoundToAll(PLAY, _, 60, _, _, 0.2);

There used to play music from net site, when we had still MOTD, it opened web page which played music background.
__________________
Do not Private Message @me
Bacardi 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 23:39.


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