-   
-     #include <amxmodx> 
-     #include <amxmisc> 
-   
-   
-         new const 
-     // _________________________________________________ 
-   
-             PLUGIN [] = "Alternative End Round Sounds", 
-             VERSION[] = "2.3b", 
-             AUTHOR [] = "Arkshine"; 
-     // _________________________________________________ 
-   
-   
-     #if AMXX_VERSION_NUM < 180 
-         #define old_amxx 
-     #endif 
-   
-   
-     /* ========================= [ "START" AERA FOR CHANGES ] ========================= */ 
-   
-   
-         #define _DEBUG                 // Active debug 
-         #define MAX_FILE_LENGTH  196   // Max length for files + path. 
-   
-         #if defined old_amxx 
-             #define MAX_SOUNDS    25   // Max sounds per team 
-         #endif 
-   
-         new const 
-   
-             g_FileName[]    = "roundsound",     // Name of the main file if no files is found in 'g_FileFolder'. 
-             g_FileFolder[]  = "round_sound",    // Name of the directory in amxmodx/configs/ for per-map files. 
-             g_FilePrefix[]  = "ini",            // File extension used for the files. 
-             g_CmdChat[]     = "/roundsound";    // Chat command for player. 
-   
-   
-     /* ========================= [ "END" AERA FOR CHANGES ] ========================= */ 
-   
-   
-   
-     // - - - - - - - - - - - - - - - - - - - - - - - 
-   
-     #define MAX_PLAYERS  32 
-     #define TASKID_ADS   1333 
-     #define SIZE_FILE    0 
-     #define NULL        -1 
-   
-     new 
-         bool:g_pHeardSound[ MAX_PLAYERS + 1 ], 
-   
-         #if !defined old_amxx 
-             Array:g_lstSoundCT, 
-             Array:g_lstSoundT, 
-         #endif 
-   
-         p_enabled, 
-         p_player_toggle, 
-         p_time_ads, 
-         p_random_precache, 
-   
-         g_sRp_value[12], 
-         g_msgSayText; 
-   
-   
-     enum _:e_Team 
-     { 
-         T = 0, 
-         CT, 
-     }; 
-   
-     new g_nSnd[ e_Team ]; 
-   
-     #if defined old_amxx 
-         new g_sTeam_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ]; 
-         #define charsmax(%1)  sizeof( %1 ) - 1 
-     #endif 
-   
-     #define _is_wav(%1)  equali( %1[strlen( %1 ) - 4 ], ".wav" ) 
-   
-     // - - - - - - - - - - - - - - - - - - - - - - - 
-   
-   
-     public plugin_precache() 
-     { 
-         register_dictionary( "end_roundsound.txt" ); 
-   
-         if( ( p_random_precache = get_cvar_pointer( "erc_random_precache" ) ) ) 
-             get_pcvar_string( p_random_precache, g_sRp_value, charsmax( g_sRp_value ) ); 
-   
-         if( !p_random_precache ) 
-             return; 
-   
-         #if !defined old_amxx 
-             g_lstSoundCT = ArrayCreate( MAX_FILE_LENGTH ); 
-             g_lstSoundT  = ArrayCreate( MAX_FILE_LENGTH ); 
-         #endif 
-   
-         loading_file(); 
-     } 
-   
-   
-     public plugin_init() 
-     { 
-         register_plugin( PLUGIN, VERSION, AUTHOR ); 
-         register_cvar( "ers_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY ); 
-   
-         register_event( "SendAudio", "eT_win" , "a", "2&%!MRAD_terwin" ); 
-         register_event( "SendAudio", "eCT_win", "a", "2&%!MRAD_ctwin"  ); 
-   
-         p_enabled         = register_cvar( "ers_enabled"        , "1"   ); 
-         p_player_toggle   = register_cvar( "ers_player_toggle"  , "1"   ); 
-         p_time_ads        = register_cvar( "erc_time_ads"       , "120" ); 
-   
-         if( !p_random_precache ) 
-         { 
-             register_cvar( "erc_random_precache", g_sRp_value ); 
-             server_cmd( "restart" ); 
-         } 
-   
-         register_clcmd( "say"       , "cmd_Say" ); 
-         register_clcmd( "say_team"  , "cmd_Say" ); 
-   
-         g_msgSayText = get_user_msgid( "SayText" ); 
-     } 
-   
-   
-     public client_authorized( id ) 
-         g_pHeardSound[id] = true; 
-   
-   
-     public client_disconnect( id ) 
-     { 
-         g_pHeardSound[id] = true; 
-         remove_task( id + TASKID_ADS ); 
-     } 
-   
-   
-     public client_putinserver( id ) 
-     { 
-         new Float:time = get_pcvar_float( p_time_ads ); 
-   
-         if( !time ) 
-             return; 
-   
-         remove_task( id + TASKID_ADS ); 
-         set_task( time, "show_ads", id + TASKID_ADS, _, _, "b" ); 
-     } 
-   
-   
-     public show_ads( taskid ) 
-     { 
-         new id = taskid - TASKID_ADS; 
-         ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat ); 
-     } 
-   
-   
-     public cmd_Say( id ) 
-     { 
-         if( !get_pcvar_num( p_enabled ) ) 
-             return PLUGIN_CONTINUE; 
-   
-         static sMsg[64]; 
-         read_argv( 1, sMsg, charsmax( sMsg ) ); 
-   
-         if( equali( sMsg, g_CmdChat ) ) 
-         { 
-             if( !get_pcvar_num( p_player_toggle ) ) 
-             { 
-                 ShowPrint( id, "%L", id, "ERS_CMD_DISABLED" ); 
-                 return PLUGIN_HANDLED; 
-             } 
-   
-             g_pHeardSound[id] = g_pHeardSound[id] ? false : true; 
-             ShowPrint( id, "%L", id, g_pHeardSound[id] ? "ERS_SOUND_ENABLED" : "ERS_SOUND_DISABLED" ); 
-   
-             return PLUGIN_HANDLED; 
-         } 
-   
-         return PLUGIN_CONTINUE; 
-     } 
-   
-   
-     public eT_win() 
-     { 
-         if( !g_nSnd[ e_Team:T ] ) 
-             return; 
-   
-         play_sound( e_Team:T ); 
-     } 
-   
-   
-     public eCT_win() 
-     { 
-         if( !g_nSnd[ e_Team:CT ] ) 
-             return; 
-   
-         play_sound( e_Team:CT ); 
-     } 
-   
-   
-     play_sound( iTeam ) 
-     { 
-         static 
-     //  - - - - - - - - - - - - - - - - 
-             sCurSnd[ MAX_FILE_LENGTH ]; 
-     //  - - - - - - - - - - - - - - - - 
-   
-         new iRand; 
-   
-         if( g_nSnd[ iTeam ] > 1 ) 
-             iRand = random( g_nSnd[ iTeam ] ); 
-   
-         #if defined old_amxx 
-             copy( sCurSnd, MAX_FILE_LENGTH - 1, g_sTeam_sounds[ iRand ][ iTeam ] ); 
-         #else 
-             ArrayGetString( iTeam == CT ? g_lstSoundCT : g_lstSoundT, iRand, sCurSnd, MAX_FILE_LENGTH - 1 ); 
-         #endif 
-   
-         _is_wav( sCurSnd ) ? 
-   
-              format( sCurSnd, MAX_FILE_LENGTH - 1, "spk %s", sCurSnd[6] ) : 
-              format( sCurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", sCurSnd ); 
-   
-         if( get_pcvar_num( p_player_toggle ) ) 
-         { 
-             static 
-         //  - - - - - - - - - - - 
-                 iPlayers[32], 
-                 iNum, pid; 
-         //  - - - - - - - - - - - 
-   
-             get_players( iPlayers, iNum, "c" ); 
-   
-             for( new i; i < iNum; i++ ) 
-             { 
-                 pid = iPlayers[i]; 
-   
-                 if( !g_pHeardSound[pid] || is_user_bot( pid ) ) 
-                     continue; 
-   
-                 client_cmd( pid, "%s", sCurSnd ); 
-             } 
-         } 
-         else 
-             client_cmd( 0, "%s", sCurSnd ); 
-     } 
-   
-   
-     get_prefix( sMap[], iLen_map, sMapType[], iLen_type ) 
-     { 
-         new 
-     //  - - - - - - - - - 
-             sRest[32]; 
-     //  - - - - - - - - - 
-   
-         get_mapname( sMap, iLen_map ); 
-         strtok( sMap, sMapType, iLen_type, sRest, charsmax( sRest ), '_', 1 ); 
-     } 
-   
-   
-     loading_file() 
-     { 
-         static 
-     //  - - - - - - - - - - - - - - - - - 
-             sPath[ MAX_FILE_LENGTH ], 
-     //      | 
-             sConfigsDir[64], 
-             sPrefix[6], 
-             sMap[32]; 
-     //  - - - - - - - - - - - - - - - - - 
-   
-         get_prefix( sMap, charsmax( sMap ), sPrefix, charsmax( sPrefix ) ); 
-         get_configsdir( sConfigsDir, charsmax( sConfigsDir ) ); 
-   
-   
-         new bool:bFound; 
-   
-         for( new i = 1; i <= 3; i++ ) 
-         { 
-             switch( i ) 
-             { 
-                 case 1 : formatex( sPath, charsmax( sPath ), "%s/%s/prefix-%s.%s", sConfigsDir, g_FileFolder, sPrefix, g_FilePrefix ); 
-                 case 2 : formatex( sPath, charsmax( sPath ), "%s/%s/%s.%s", sConfigsDir, g_FileFolder, sMap, g_FilePrefix ); 
-                 case 3 : formatex( sPath, charsmax( sPath ), "%s/%s.%s", sConfigsDir, g_FileName, g_FilePrefix ); 
-   
-                 default : break; 
-             } 
-   
-             if( !CheckFile( sPath ) ) 
-                 continue; 
-   
-             bFound = true; 
-             break; 
-         } 
-   
-         log_amx( "---" ); 
-   
-         bFound ? 
-             log_amx( "%L", LANG_SERVER, "ERS_LOG_LOADING", sPath ) : 
-             log_amx( "%L", LANG_SERVER, "ERS_LOG_NO_FILES_FOUND" ); 
-   
-         load_sound( sPath ); 
-     } 
-   
-   
-     load_sound( const file[] ) 
-     { 
-         new 
-     //  - - - - - - - - - - - - - - - 
-             sBuffer[256], 
-     //      | 
-             sLeft[ MAX_FILE_LENGTH ], 
-             sRight[4], 
-             sExt[6], 
-     //      | 
-             eTeam; 
-     //  - - - - - - - - - - - - - - - 
-   
-         new fp = fopen( file, "rt" ); 
-   
-         while( !feof( fp ) ) 
-         { 
-             fgets( fp, sBuffer, charsmax( sBuffer ) ); 
-   
-             trim( sBuffer ); 
-   
-             if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) ) 
-                 continue; 
-   
-             if( sBuffer[0] != '"' || strlen( sBuffer  ) < 11 ) 
-                 continue; 
-   
-             parse( sBuffer, sLeft, charsmax( sLeft ), sRight, charsmax( sRight ) ); 
-             formatex( sExt, charsmax( sExt ), sLeft[ strlen( sLeft ) - 4 ] ); 
-   
-             if( equali( sExt, ".mp3" ) == -1 || equali( sExt, ".wav" ) == -1 ) 
-             { 
-                 log_amx( "%L", LANG_SERVER, "ERS_LOG_UNKNOW_EXTENSION", sExt ); 
-                 continue; 
-             } 
-   
-             if( !file_exists( sLeft ) ) 
-             { 
-                 log_amx( "%L", LANG_SERVER, "ERS_LOG_INEXISTENT_FILE", sLeft ); 
-                 continue; 
-             } 
-   
-             eTeam = NULL; 
-   
-             if( equali( sRight, "CT" ) ) 
-                 eTeam = CT; 
-   
-             else if( equali( sRight, "T" ) ) 
-                 eTeam = T; 
-   
-             if( eTeam == NULL ) 
-             { 
-                 log_amx( "%L", LANG_SERVER, "ERS_LOG_NO_TEAM_SOUND", sLeft ); 
-                 continue; 
-             } 
-   
-             #if defined old_amxx 
-                 copy( g_sTeam_sounds[ g_nSnd[ eTeam ] ][ eTeam ], MAX_FILE_LENGTH - 1, sLeft ); 
-             #else 
-                 ArrayPushString( eTeam == CT ? g_lstSoundCT : g_lstSoundT, sLeft ); 
-             #endif 
-   
-             ++g_nSnd[ eTeam ]; 
-         } 
-         fclose( fp ); 
-   
-         if( g_nSnd[ e_Team:T ] > 1 || g_nSnd[ e_Team:CT ] > 1 ) 
-         { 
-                 new iMax_t, iMax_ct; 
-                 GetPrecacheValue( iMax_t, iMax_ct ); 
-   
-                 #if defined old_amxx 
-                     UpdateArray( iMax_t, e_Team:T ); 
-                     UpdateArray( iMax_ct, e_Team:CT ); 
-                 #else 
-                     p_DeleteRandomItem( iMax_t , e_Team:T , g_lstSoundT  ); 
-                     p_DeleteRandomItem( iMax_ct, e_Team:CT, g_lstSoundCT ); 
-                 #endif 
-         } 
-   
-         log_amx( "---" ); 
-   
-         #if defined _DEBUG 
-             log_amx( "[ Loading %d CTs Sounds ]", g_nSnd[ e_team:CT ] ); 
-         #endif 
-         #if defined old_amxx 
-             PrecacheSounds( e_Team:CT ); 
-         #else 
-             PrecacheSounds_n( g_lstSoundCT ); 
-         #endif 
-   
-         #if defined _DEBUG 
-              log_amx( "[ Loading %d Ts Sounds ]", g_nSnd[ e_team:T ] ); 
-         #endif 
-         #if defined old_amxx 
-             PrecacheSounds( e_Team:T ); 
-         #else 
-             PrecacheSounds_n( g_lstSoundT ); 
-         #endif 
-     } 
-   
-   
-     GetPrecacheValue( &iMax_t, &iMax_ct ) 
-     { 
-         trim( g_sRp_value ); 
-         new pos = contain( g_sRp_value, "-" ); 
-   
-         if( pos > 0 ) 
-         { 
-             iMax_ct = str_to_num( g_sRp_value[ pos + 1 ] ) 
-             g_sRp_value[ pos ] = '^0'; 
-             iMax_t = str_to_num( g_sRp_value ); 
-         } 
-         else 
-         { 
-             iMax_t  = str_to_num( g_sRp_value ); 
-             iMax_ct = iMax_t; 
-         } 
-     } 
-   
-   
-     stock UpdateArray( iMax, iTeam ) 
-     { 
-         new const iCnt_sound = g_nSnd[ iTeam ]; 
-   
-         if( !iMax || iMax == iCnt_sound ) 
-             return; 
-   
-         if( iMax >= iCnt_sound ) 
-             iMax = iCnt_sound - 1; 
-   
-         static 
-             sTmp_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ], 
-             iLast_number[ MAX_SOUNDS ]; 
-   
-         new i, iRand; 
-         for( i = 0; i < iCnt_sound; i++ ) 
-         { 
-             copy( sTmp_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, g_sTeam_sounds[i][ iTeam ] ); 
-             g_sTeam_sounds[i][ iTeam ][0] = '^0'; 
-         } 
-   
-         arrayset( iLast_number, 0, charsmax( iLast_number ) ); 
-   
-         i = 0; 
-         while( i != iMax ) 
-         { 
-             check: 
-             iRand = random( iCnt_sound ); 
-   
-             if( iLast_number[ iRand ] ) 
-                 goto check; 
-   
-             copy( g_sTeam_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, sTmp_sounds[ iRand ][ iTeam ] ); 
-             ++i; 
-   
-             iLast_number[ iRand ] = 1; 
-         } 
-   
-         g_nSnd[ iTeam ] = iMax; 
-     } 
-   
-   
-     stock p_DeleteRandomItem( iMax, iTeam, Array:sSound_a ) 
-     { 
-         new const iCnt_sound = g_nSnd[ iTeam ]; 
-   
-         if( !iMax || iMax == iCnt_sound ) 
-             return; 
-   
-         if( iMax >= iCnt_sound ) 
-             iMax = iCnt_sound - 1; 
-   
-         DeleteRandomItem( iCnt_sound - iMax, sSound_a ); 
-         g_nSnd[ iTeam ] = iMax; 
-     } 
-   
-   
-     stock DeleteRandomItem( iRandom_n, Array:sSound_a ) 
-         { 
-             new i; 
-   
-             while( i++ != iRandom_n ) 
-                 ArrayDeleteItem( sSound_a, random( ArraySize( sSound_a ) ) ); 
-         } 
-   
-   
-     stock PrecacheSounds( iTeam ) 
-     { 
-         for( new i; i < g_nSnd[ iTeam ]; i++ ) 
-         { 
-             PrecacheFile( g_sTeam_sounds[i][ iTeam ] ); 
-   
-             #if defined _DEBUG 
-                 log_amx( "   - %s", g_sTeam_sounds[i][ iTeam ] ); 
-             #endif 
-         } 
-   
-         log_amx( "---" ); 
-     } 
-   
-   
-     stock PrecacheSounds_n( Array:sSound_a ) 
-     { 
-         static 
-     //  - - - - - - - - - - - - - - - - - - - 
-             sFile[ MAX_FILE_LENGTH ], 
-             iFileLen = charsmax( sFile ); 
-     //  - - - - - - - - - - - - - - - - - - - 
-   
-         for( new i; i < ArraySize( sSound_a ); i++ ) 
-         { 
-             ArrayGetString( sSound_a, i, sFile, iFileLen ); 
-             PrecacheFile( sFile ); 
-   
-             #if defined _DEBUG 
-                 log_amx( "   - %s", sFile ); 
-             #endif 
-         } 
-   
-          log_amx( "---" ); 
-     } 
-   
-   
-     PrecacheFile( const sound[] ) 
-     { 
-         _is_wav( sound ) ? 
-   
-             precache_sound( sound[6] ) : 
-             precache_generic( sound ); 
-     } 
-   
-   
-     ShowPrint( id, const sMsg[], { Float, Sql, Result, _ }:... ) 
-     { 
-         static 
-     //  - - - - - - - - - 
-             newMsg[191], 
-             message[191], 
-     //      | 
-             tNewMsg; 
-     //  - - - - - - - - - 
-   
-         tNewMsg = charsmax( newMsg ); 
-         vformat( newMsg, tNewMsg, sMsg, 3 ); 
-   
-         replace_all( newMsg, tNewMsg, "!t", "^3" ); 
-         replace_all( newMsg, tNewMsg, "!g", "^4" ); 
-         replace_all( newMsg, tNewMsg, "!n", "^1" ); 
-   
-         formatex( message, charsmax( message ), "^4[ERS]^1 %s", newMsg ); 
-   
-         emessage_begin( MSG_ONE, g_msgSayText, _, id ); 
-         ewrite_byte( id ); 
-         ewrite_string( message ); 
-         emessage_end(); 
-     } 
-   
-   
-     bool:CheckFile( const file[] ) 
-     { 
-         new 
-     //  - - - - - - - - - - - - - - - - - 
-             sBuffer[256], 
-             fp = fopen( file, "rt" ); 
-     //  - - - - - - - - - - - - - - - - - 
-   
-         if( !fp ) 
-             return false; 
-   
-         while( !feof( fp ) ) 
-         { 
-             fgets( fp, sBuffer, charsmax( sBuffer ) ); 
-   
-             trim( sBuffer ); 
-   
-             if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) || sBuffer[0] != '"' ) 
-                 continue; 
-   
-             if( ( contain( sBuffer, ".mp3^"" ) != -1 || contain( sBuffer, ".wav^"" ) != -1 ) && ( contain( sBuffer, "^"T^"" ) != -1 || contain( sBuffer, "^"CT^"" ) != -1 ) ) 
-                 return true; 
-         } 
-         fclose( fp ); 
-   
-         return false; 
-     } 
- /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE 
- *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par } 
- */ 
-