Raised This Month: $ Target: $400
 0% 

Music After Laying the Bomb


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RAIN182
Member
Join Date: Dec 2013
Location: Volgograd , Russian Fede
Old 03-11-2022 , 08:39   Music After Laying the Bomb
Reply With Quote #1

Source code

PHP Code:
#include <sdktools>

float fVolume 1.0;

ArrayList hArray

public 
Plugin myinfo =
{
    
name "Bomb sound",
    
description "",
    
author "Fleeeshi",
    
version "1.0.0",
    
url "disscord: Fleeeshi#4704"
};

public 
OnPluginStart() {
    
hArray = new ArrayList(ByteCountToCells(128));
    
HookEvent("bomb_planted"OnBombPlanted);
}

public 
void OnMapStart() {
    
LoadSound();
}

void LoadSound() {
    
hArray.Clear();
    
char sPath[256];
    
BuildPath(Path_SMsPathsizeof(sPath), "configs/bomb_sound.txt");
    
Handle szFile OpenFile(sPath"r"false"GAME");
    
char buffer[128];
    while (
ReadFileLine(szFilebuffer128))
    {
        
TrimString(buffer);
        
hArray.PushString(buffer);
        
        
char sBuffer[128];
        
Format(sBuffer128"sound/%s"buffer);
        
AddFileToDownloadsTable(sBuffer);
        
PrecacheSound(buffertrue);
    }
    
CloseHandle(szFile);
}

public 
Action OnBombPlanted(Event hEvent, const char[] namebool dontBroadcast) {
    
int Len hArray.Length;
    
char szBuffer[128];
    if(
Len 0) {
        
hArray.GetString(GetRandomInt(0Len-1), szBuffersizeof(szBuffer));
    }
    for(
int i 1<= MaxClientsi++) {
        if(
IsClientInGame(i) && !IsFakeClient(i) && (!IsPlayerAlive(i) || GetClientTeam(i) == 1)) {
            
EmitSoundToClient(iszBuffer_SNDCHAN_STATIC__fVolume);
        }
    }

Music is played once .
But everything works well in observers.
I need music to play with all the dead players and observers after laying the bomb.
Please help.Sorry about my bad English.
:-)
RAIN182 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-11-2022 , 11:57   Re: Music After Laying the Bomb
Reply With Quote #2

Try... without change channel flag.

spectators are dead.


PHP Code:
    for(int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || IsPlayerAlive(i))
            continue;

        
EmitSoundToClient(iszBuffer, .volume fVolume);
    } 
__________________
Do not Private Message @me
Bacardi is offline
RAIN182
Member
Join Date: Dec 2013
Location: Volgograd , Russian Fede
Old 03-12-2022 , 13:37   Re: Music After Laying the Bomb
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
Try... without change channel flag.

spectators are dead.


PHP Code:
    for(int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || IsPlayerAlive(i))
            continue;

        
EmitSoundToClient(iszBuffer, .volume fVolume);
    } 
The problem remained, the music plays very quietly or in the background.
RAIN182 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-12-2022 , 16:00   Re: Music After Laying the Bomb
Reply With Quote #4

Spoiler

Aa, now I get it, why you heard it silent.

If you observer player when dead or spectate -> silent or even stop.
But when you free look/fly around as dead or spectator, normal sound.

I have not found that behaviour before.

*edit
Maybe need use play commands. Setting volume is now hard to use...
PHP Code:
#include <sdktools>

/*
Server event "bomb_planted", Tick 15875:
- "userid" = "6"
- "site" = "302"
*/
public void OnPluginStart()
{
    
HookEvent("bomb_planted"bomb_planted);
}

public 
void bomb_planted(Event event, const char[] namebool dontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || !IsFakeClient(i) || !IsPlayerAlive(i))
            continue;
        
        
PrecacheSound("music/halflife_alyx_01/startround_01.mp3");
        
ClientCommand(i"playgamesound \"music/halflife_alyx_01/startround_01.mp3\"");
    }

__________________
Do not Private Message @me

Last edited by Bacardi; 03-12-2022 at 16:43.
Bacardi is offline
RAIN182
Member
Join Date: Dec 2013
Location: Volgograd , Russian Fede
Old 03-12-2022 , 21:45   Re: Music After Laying the Bomb
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
Spoiler

Aa, now I get it, why you heard it silent.

If you observer player when dead or spectate -> silent or even stop.
But when you free look/fly around as dead or spectator, normal sound.

I have not found that behaviour before.

*edit
Maybe need use play commands. Setting volume is now hard to use...
PHP Code:
#include <sdktools>

/*
Server event "bomb_planted", Tick 15875:
- "userid" = "6"
- "site" = "302"
*/
public void OnPluginStart()
{
    
HookEvent("bomb_planted"bomb_planted);
}

public 
void bomb_planted(Event event, const char[] namebool dontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || !IsFakeClient(i) || !IsPlayerAlive(i))
            continue;
        
        
PrecacheSound("music/halflife_alyx_01/startround_01.mp3");
        
ClientCommand(i"playgamesound \"music/halflife_alyx_01/startround_01.mp3\"");
    }

PHP Code:
#include <sdktools>

/*
Server event "bomb_planted", Tick 15875:
- "userid" = "6"
- "site" = "302"
*/
public void OnPluginStart()
{
    
HookEvent("bomb_planted"bomb_planted);
}

public 
void bomb_planted(Event event, const char[] namebool dontBroadcast)
{
    for(
int i 1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i) || !IsFakeClient(i) || !IsPlayerAlive(i))
            continue;
        
        
PrecacheSound("misc/cyber_vlg_bomb_sound/bomb_sound_01.mp3");
        
PrecacheSound("misc/cyber_vlg_bomb_sound/bomb_sound_02.mp3");
        
PrecacheSound("misc/cyber_vlg_bomb_sound/bomb_sound_03.mp3");
        
PrecacheSound("misc/cyber_vlg_bomb_sound/bomb_sound_04.mp3");
        
PrecacheSound("misc/cyber_vlg_bomb_sound/bomb_sound_05.mp3");
        
ClientCommand(i"playgamesound \"misc/cyber_vlg_bomb_sound/bomb_sound_01.mp3\"");
        
ClientCommand(i"playgamesound \"misc/cyber_vlg_bomb_sound/bomb_sound_02.mp3\"");
        
ClientCommand(i"playgamesound \"misc/cyber_vlg_bomb_sound/bomb_sound_03.mp3\"");
        
ClientCommand(i"playgamesound \"misc/cyber_vlg_bomb_sound/bomb_sound_04.mp3\"");
        
ClientCommand(i"playgamesound \"misc/cyber_vlg_bomb_sound/bomb_sound_05.mp3\"");
    }

Am I adding music right?
RAIN182 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-13-2022 , 01:55   Re: Music After Laying the Bomb
Reply With Quote #6

Now you would play multiple sounds together.

Your previous code is, ok?
But replace EmitSound to
ClientCommand(i, "playgamesound %s", szBuffer);


I posted quick example, so you can test Alyx sound, will it work like you wanted.
__________________
Do not Private Message @me
Bacardi is offline
RAIN182
Member
Join Date: Dec 2013
Location: Volgograd , Russian Fede
Old 03-13-2022 , 05:34   Re: Music After Laying the Bomb
Reply With Quote #7

Quote:
Originally Posted by Bacardi View Post
Now you would play multiple sounds together.

Your previous code is, ok?
But replace EmitSound to
ClientCommand(i, "playgamesound %s", szBuffer);


I posted quick example, so you can test Alyx sound, will it work like you wanted.
It seems to work.
I am still testing and in a couple of days I will write the result.
RAIN182 is offline
RAIN182
Member
Join Date: Dec 2013
Location: Volgograd , Russian Fede
Old 03-14-2022 , 09:24   Re: Music After Laying the Bomb
Reply With Quote #8

Everything works.
Thank you very much for your help.
RAIN182 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 07:25.


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