Raised This Month: $ Target: $400
 0% 

Solved Prevent background sound from overlapping between rounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 09:55   Prevent background sound from overlapping between rounds
Reply With Quote #1

I got this code from some archived post: https://forums.alliedmods.net/archiv...p/t-53052.html

The code starts playing the defined sound after each new round start...all fine,
the problem is that the sound file i added works as an background music.
That ambience sound lasts about 3 min,if the round ends in 30 sec it will continue playing and another sample of the same ambience will start playing with new round start.

What can i add to the code so that round start sound stops right before starting a new round??

Code as of now:

PHP Code:
#include <amxmodx>

new const lstSound[][] = { "misc/predatortheme.wav" };
new 
bool:g_handle_round_end;

public 
plugin_init() 
{
register_plugin"Round Start Sound""1.0""AMXX Community" );
register_event"HLTV""event_new_round""a""1=0""2=0" );
register_logevent("EventRoundEnd"2"1=Round_End");
}

public 
plugin_precache() 
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if ( 
equaliCurSnd[strlen(CurSnd)-4], ".mp3" ) ) 
{
if ( 
file_existsCurSnd ) )
precache_genericCurSnd );
}
else 
{
if ( 
file_existsCurSnd ) )
precache_soundCurSnd[6] ); 
}
}

public 
event_new_round()
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if( 
equaliCurSnd[strlenCurSnd ) - ], ".mp3" ) )
client_cmd0"mp3 play %s"CurSnd )
else
client_cmd0"spk %s"CurSnd[6] )

}

public 
EventRoundEnd()
{
  if( !
g_handle_round_end ) return;
  
  
g_handle_round_end false;

 
client_cmd (CurSnd "stopsound" )

I ony added:

PHP Code:
new bool:g_handle_round_end

register_logevent("EventRoundEnd"2"1=Round_End");

and

public 
EventRoundEnd()
{
  if( !
g_handle_round_end ) return;
  
  
g_handle_round_end false;

 
client_cmd (CurSnd "stopsound" )

to the original code but im getting the following errors:

Warning: Loose indentation on line 52
Error: Undefined symbol "CurSnd" on line 52
Warning: Expression has no effect on line 52
Error: Expected token: ";", but found ")" on line 52
Error: Invalid expression, assumed zero on line 52
Error: Too many error messages on one line on line 52


What im doing wrong,can you guys help me out??

Thanks everyone

Edu

Last edited by chuttenjr; 09-29-2018 at 12:54.
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-27-2018 , 09:57   Re: Prevent background sound from overlapping between rounds
Reply With Quote #2

Stop previous sound before starting new one.
To stop mp3, use client_cmd & "mp3 stop"
To stop wav, use client_cmd & "stopsound"
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 10:37   Re: Prevent background sound from overlapping between rounds
Reply With Quote #3

I tried this,added to:

PHP Code:
public plugin_init(

register_event ("HLTV""EventRoundEnd","a","1"
and at the end of code:

PHP Code:
public EventRoundEnd() 
{
client_cmd1"stopsound""misc/predatortheme.wav" 


now sound does not play at all

Last edited by chuttenjr; 09-27-2018 at 10:38. Reason: adding testing
chuttenjr is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 09-27-2018 , 21:16   Re: Prevent background sound from overlapping between rounds
Reply With Quote #4

Quote:
Originally Posted by chuttenjr View Post
I tried this,added to:

PHP Code:
public plugin_init(

register_event ("HLTV""EventRoundEnd","a","1"
and at the end of code:

PHP Code:
public EventRoundEnd() 
{
client_cmd1"stopsound""misc/predatortheme.wav" 


now sound does not play at all
You need to stop and start again, or stop on endround and start on newround.
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-27-2018 , 22:00   Re: Prevent background sound from overlapping between rounds
Reply With Quote #5

Preferably ,stop on end round and start on newround
chuttenjr is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 09-28-2018 , 02:27   Re: Prevent background sound from overlapping between rounds
Reply With Quote #6

PHP Code:
client_cmd(0"stopsound"); 
__________________
Airkish is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-28-2018 , 07:52   Re: Prevent background sound from overlapping between rounds
Reply With Quote #7

PHP Code:
#include <amxmodx>

new const lstSound[][] = { "misc/predatortheme.wav" };

public 
plugin_init() 
{
register_plugin"Round Start Sound""1.0""AMXX Community" );
register_event"HLTV""event_new_round""a""1=0""2=0" );
register_event ("HLTV""EventRoundEnd","a","1")
}

public 
plugin_precache() 
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if ( 
equaliCurSnd[strlen(CurSnd)-4], ".mp3" ) ) 
{
if ( 
file_existsCurSnd ) )
precache_genericCurSnd );
}
else 
{
if ( 
file_existsCurSnd ) )
precache_soundCurSnd[6] ); 
}
}

public 
event_new_round()
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if( 
equaliCurSnd[strlenCurSnd ) - ], ".mp3" ) )
client_cmd0"mp3 play %s"CurSnd )
else
client_cmd0"spk %s"CurSnd[6] )

}

public 
EventRoundEnd()  

client_cmd(0"stopsound"); 

Now the mp3 doesnt play at all,and i am getting various sound cuts (shots,radio,ambience etc...)
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-28-2018 , 08:21   Re: Prevent background sound from overlapping between rounds
Reply With Quote #8

"Now the mp3 doesnt play at all"
I can't see any mp3 format sounds


stopsound stops every sound. If you want to keep other sounds then convert your .wav to .mp3 and use mp3 play/mp3 stop
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 09-28-2018 at 08:22.
Ghosted is offline
chuttenjr
Member
Join Date: Sep 2018
Location: Saipan
Old 09-28-2018 , 08:28   Re: Prevent background sound from overlapping between rounds
Reply With Quote #9

Changed .wav file to .mp3,file plays on every round start overlapping itself

PHP Code:
#include <amxmodx>

new const lstSound[][] = { "misc/predatortheme.mp3" };

public 
plugin_init() 
{
register_plugin"Round Start Sound""1.0""AMXX Community" );
register_event"HLTV""event_new_round""a""1=0""2=0" );
register_event ("HLTV""EventRoundEnd","a","1")
}

public 
plugin_precache() 
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if ( 
equaliCurSnd[strlen(CurSnd)-4], "predatortheme.mp3" ) ) 
{
if ( 
file_existsCurSnd ) )
precache_genericCurSnd );
}
else 
{
if ( 
file_existsCurSnd ) )
precache_soundCurSnd[6] ); 
}
}

public 
event_new_round()
{
new 
CurSnd[128];

copyCurSnd127lstSound[0] );
formatCurSnd127"sound/%s"CurSnd ); 

if( 
equaliCurSnd[strlenCurSnd ) - ], "predatortheme.mp3" ) )
client_cmd0"mp3 play %s"CurSnd )
else
client_cmd0"spk %s"CurSnd[6] )

}
public 
EventRoundEnd()   
{  
client_cmd(0"mp3 stop");  


Last edited by chuttenjr; 09-28-2018 at 08:50. Reason: Finished testing
chuttenjr is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 09-28-2018 , 08:57   Re: Prevent background sound from overlapping between rounds
Reply With Quote #10

Why do you have "mp3 stop" in different function. WHY NOT JUST ADD BEFORE "mp3 play" ?
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted 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 00:22.


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