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

[Solved] Background Ambience on roundstart


Post New Thread Reply   
 
Thread Tools Display Modes
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 09-04-2011 , 15:39   Re: [Solved] Background Ambience on roundstart
Reply With Quote #21

Forgot
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
vaan123
Veteran Member
Join Date: Sep 2009
Location: Kuwait
Old 09-04-2011 , 22:10   Re: [Solved] Background Ambience on roundstart
Reply With Quote #22

Didn't work, i can download the sounds but nothing plays ingame, also i checked the logs and there's nothing in there.
__________________

vaan123 is offline
Send a message via MSN to vaan123 Send a message via Yahoo to vaan123 Send a message via Skype™ to vaan123
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 09-04-2011 , 23:04   Re: [Solved] Background Ambience on roundstart
Reply With Quote #23

Quote:
Originally Posted by vaan123 View Post
Didn't work, i can download the sounds but nothing plays ingame, also i checked the logs and there's nothing in there.
EDIT: Something is wrong with using the external files right now. Trying to get it fixed. However, the default sounds in the plugin work with this code, if you would like to use it in the meantime:

EDIT EDIT: Plugin should be working flawlessly now. Let me know if any bugs show up.

PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

#define TASK_LOOPSOUND 1000

new g_szDefaultSounds[ ][ ] = 
{
    
"music1.mp3",
    
"music2.mp3"
}

new Array:
g_aSounds;

new 
bool:g_bFileExists;

new 
g_pPluginOn;
new 
g_pSoundChange;

new 
g_iRandom;

new 
g_iRoundNumber;

public 
plugin_init()
{
    
register_plugin"Background Sounds""1.0""H3avY Ra1n" );

    
register_event"HLTV""Event_RoundStart""a""1=0""2=0" );

    
register_logevent"LogEvent_RoundEnd"2"1=Round_End" );

    
g_pPluginOn register_cvar"ba_ambience""1" );
    
g_pSoundChange register_cvar"ba_sound_each_rounds""1" );
}

public 
plugin_precache()
{
    
g_aSounds ArrayCreate256 );

    new 
szDirectory256 ], szMapName32 ];
    
get_configsdirszDirectorycharsmaxszDirectory ) );

    
get_mapnameszMapNamecharsmaxszMapName ) );

    
formatszDirectorycharsmaxszDirectory ), "%s/sounds/%s.ini"szDirectoryszMapName );


    
g_bFileExists bool:file_existsszDirectory );

    new 
szPath256 ], bool:bSuccess;

    if( 
g_bFileExists )
    {
        new 
iFile fopenszDirectory"rt" );
        
        new 
szBuffer256 ];
        
        while( !
feofiFile ) )
        {
            
fgetsiFileszBuffercharsmaxszBuffer ) );

            
trimszBuffer );
            
            
remove_quotesszBuffer );
            
            
bSuccess false;
            
            
formatexszPathcharsmaxszPath ), "sound/%s"szBuffer );
            
            if( !
file_existsszPath ) )
            {
                
log_amx"[Background Sounds] %s does not exist."szPath );
            }
            
            else
            {
                if( 
containszBuffer".mp3" ) )
                {
                    
precache_genericszPath );
                    
bSuccess true;
                }
                
                else if( 
containszBuffer".wav" ) )
                {
                    
precache_soundszBuffer );
                    
bSuccess true;
                }
                
                else
                {
                    
log_amx"[Background Sounds] %s not a valid sound file."szPath );
                }
            }
            
            if( 
bSuccess )
                
ArrayPushStringg_aSoundsszBuffer );
        }
        
        
fcloseiFile );
    }

    else
    {
        for( new 
0sizeof g_szDefaultSoundsi++ )
        {
            
bSuccess false;
            
            
formatexszPathcharsmaxszPath ), "sound/%s"g_szDefaultSounds] );
            
            if( !
file_existsszPath ) )
            {
                
log_amx"[Background Sounds] %s does not exist."szPath );
            }
            
            else
            {
                if( 
containg_szDefaultSounds], ".mp3" ) )
                {
                    
precache_genericszPath );
                    
bSuccess true;
                }
                
                else if( 
containg_szDefaultSounds], ".wav" ) )
                {
                    
precache_soundg_szDefaultSounds] );
                    
bSuccess true;
                }
                
                else
                {
                    
log_amx"[Background Sounds] %s not a valid sound file."szPath );
                }
            }
            
            if( 
bSuccess )
                
ArrayPushStringg_aSoundsg_szDefaultSounds] );
        }
    }
    
    new 
iSize ArraySizeg_aSounds );
    
    if( !
iSize )
        
set_fail_state"No sound files found." );
    
    else
        
g_iRandom randomiSize );
}

public 
Event_RoundStart()
{
    if( !
get_pcvar_numg_pPluginOn ) )
        return;

    if( ++
g_iRoundNumber get_pcvar_numg_pSoundChange ) == )
    {
        
g_iRandom randomArraySizeg_aSounds ) );
    }

    new 
szBuffer256 ];
    
ArrayGetStringg_aSoundsg_iRandomszBuffercharsmaxszBuffer ) );
    
    if( 
containszBuffer".mp3" ) != -)
    {
        
client_cmd0"mp3 loop ^"sound/%s^""szBuffer );
    }

    else if( 
containszBuffer".wav" ) != -)
    {
        
client_cmd0"stopsound" );
        
        new 
szPath256 ];
        
formatexszPathcharsmaxszPath ), "sound/%s"szBuffer );
        
        
client_cmd0"spk ^"%s^""szPath );
        
        
set_taskGetWavDurationszPath ), "Task_LoopSound"TASK_LOOPSOUNDszBuffercharsmaxszBuffer ), .flags="b" );
    }
}

public 
LogEvent_RoundEnd()
{    
    
client_cmd0"stopsound" );
    
client_cmd0"mp3 stop" );
    
    
remove_taskTASK_LOOPSOUND );
}

public 
Task_LoopSoundszSound[ ], iTaskID )
{
    
client_cmd0"stopsound" );
    
client_cmd0"spk ^"%s^""szSound );
}

// Provided by Arkshine
Float:GetWavDuration( const WavFile[] )
{
    new 
Frequence ];
    new 
Bitrate   ];
    new 
DataLength];
    new 
File;
    
    
// --| Open the file.
    
File fopenWavFile"rb" );
    
    
// --| Get the frequence from offset 24. ( Read 4 bytes )
    
fseekFile24SEEK_SET );
    
fread_blocksFileFrequence4BLOCK_INT );
    
    
// --| Get the bitrate from offset 34. ( read 2 bytes )
    
fseekFile34SEEK_SET ); 
    
fread_blocksFileBitrate2BLOCK_BYTE );
    
    
// --| Search 'data'. If the 'd' not on the offset 40, we search it.
    
if ( fgetcFile ) != 'd' ) while( fgetcFile ) != 'd' && !feofFile ) ) {}
    
    
// --| Get the data length from offset 44. ( after 'data', read 4 bytes )
    
fseekFile3SEEK_CUR ); 
    
fread_blocksFileDataLength4BLOCK_INT );

    
// --| Close file.
    
fcloseFile );
    
    
// --| Calculate the time. ( Data length / ( frequence * bitrate ) / 8 ).
    
return floatDataLength] ) / ( floatFrequence] * Bitrate] ) / 8.0 );

__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 09-05-2011 at 00:46.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
vaan123
Veteran Member
Join Date: Sep 2009
Location: Kuwait
Old 09-05-2011 , 07:27   Re: [Solved] Background Ambience on roundstart
Reply With Quote #24

Tested and it worked, no problems whatsoever =] thanks =]
__________________

vaan123 is offline
Send a message via MSN to vaan123 Send a message via Yahoo to vaan123 Send a message via Skype™ to vaan123
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 09-05-2011 , 09:42   Re: [Solved] Background Ambience on roundstart
Reply With Quote #25

Also released here:http://forums.alliedmods.net/showthread.php?t=166562
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
vaan123
Veteran Member
Join Date: Sep 2009
Location: Kuwait
Old 09-05-2011 , 10:57   Re: [Solved] Background Ambience on roundstart
Reply With Quote #26

Nice, this thread can be closed now.
__________________

vaan123 is offline
Send a message via MSN to vaan123 Send a message via Yahoo to vaan123 Send a message via Skype™ to vaan123
rohit ranjan
Junior Member
Join Date: Jul 2013
Location: india
Old 09-20-2013 , 16:49   Re: [Solved] Background Ambience on roundstart
Reply With Quote #27

hay nikhil nice plugin
ahh but u can add more if some one want more (like me)
it works fine but i want in on clan wars too
soo please add
round start cound including (10,9,8,7,6,5,4,3,2,1)
round start sound(upto 20 sec)
also u can make it a full applicable plugin on any mod too
just add
round end win sound
round end lost sound
zombie hit human
zombie hit wall sound
zombie swing sound
zombie killed sound
human killed sound

take the sesources from zombie escape mod
it will be really a great successfull sound player
rohit ranjan is offline
ANTICHRISTUS
kingdom of weird stuff
Join Date: Jun 2010
Location: My kingdom is not in thi
Old 09-20-2013 , 16:55   Re: [Solved] Background Ambience on roundstart
Reply With Quote #28

he made a plugin's thread about it (look above), go ask there please.
__________________
ANTICHRISTUS 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 19:25.


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