Advertisement
crywolfy

round_sounds_advanced.sma

Oct 22nd, 2013
1,482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.68 KB | None | 0 0
  1.     /**************************************************************
  2.         Round Sounds Advanced
  3.         (c) 2013 by CryWolf
  4.        
  5.         www.eXtreamCS.com
  6.         www.amxmodx.org
  7.        
  8.         Descriere: Acest plugin va ofera posibilitatea de a schimba sunetele
  9.         de la inceput de runda si cele de la sfarsit, este unic prin faptul ca ofera
  10.         suport pentru fisiere .wav si .mp3 iar sunetele de la inceput de runda inlocuiesc
  11.         sunetul radio de tip "go go go" si sunetele la sfarsit de runda Counter-Terrorist Win / Terrorist Win
  12.         cu cele din acest plugin :)
  13.        
  14.         Credite:
  15.         - Askhanar functia de precache din FMU
  16.         - Cheap_suit pentru modalitatea de a inlocui sunetele radio cu o metoda mai avansata
  17.         - PaintLancer: Pentru ideea originala!
  18.        
  19.         Changelog:
  20.        
  21.         v1.0
  22.         - Prima versiune stabila
  23.        
  24.         Licenta de tip GNU (Open Source)
  25.        
  26.         Adica, aveti voie sa modificati continutul dar nu si Autorul
  27.        
  28.         This file is part of AMX Mod X.
  29.  
  30.             Round Sounds free software: you can redistribute it and/or modify
  31.             it under the terms of the GNU General Public License as published by
  32.             the Free Software Foundation, either version 3 of the License, or
  33.             (at your option) any later version.
  34.        
  35.             RoundSounds is distributed in the hope that it will be useful,
  36.             but WITHOUT ANY WARRANTY; without even the implied warranty of
  37.             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  38.             GNU General Public License for more details.
  39.        
  40.             You should have received a copy of the GNU General Public License
  41.             along with this file.  If not, see <http://www.gnu.org/licenses/>.
  42.        
  43.     *****************************************************************/
  44.    
  45.     #include < amxmodx >
  46.     #include < amxmisc >
  47.    
  48.     #tryinclude "round_sounds_advanced.cfg"
  49.    
  50.     #pragma semicolon 1
  51.    
  52.     //Plugin registration
  53.     new const
  54.         PLUGIN_NAME [ ] = "Round Sounds Advanced",
  55.         PLUGIN_VERSION  [ ] = "1.2",
  56.         PLUGIN_AUTHOR   [ ] = "CryWolf";
  57.        
  58.     // pCvar Pointers
  59.     new pCvar_endsound, pCvar_beginsound, g_radiofix;
  60.    
  61.  
  62. public plugin_precache ( )
  63. {
  64.     pCvar_beginsound    = register_cvar ( "amxx_bsounds", "1" );
  65.     pCvar_endsound      = register_cvar ( "amxx_esounds", "1" );
  66.    
  67.     new i, path [ 128 ];
  68.    
  69.     if ( get_pcvar_num ( pCvar_beginsound ) )
  70.     {
  71.         for ( i = 0; i < sizeof g_begun_sounds; i++ )
  72.         {
  73.             if ( contain ( g_begun_sounds [ i ], ".wav" ) > 0 ) {
  74.                 precache_sound ( g_begun_sounds [ i ] );
  75.             }
  76.             else if ( contain ( g_begun_sounds [ i ], ".mp3" ) > 0 ) {
  77.                 formatex ( path, charsmax ( path ), "sound/%s", g_begun_sounds  [ i ]);
  78.                 precache_generic ( path );
  79.             }
  80.         }
  81.     }
  82.    
  83.     if ( get_pcvar_num ( pCvar_endsound ) )
  84.     {
  85.         for ( i = 0; i < sizeof g_ct_win_sounds; i++ )
  86.         {
  87.             if ( contain ( g_ct_win_sounds [ i ], ".wav" ) > 0 ) {
  88.                 precache_sound ( g_ct_win_sounds [ i ] );
  89.             }
  90.             else if ( contain ( g_ct_win_sounds [ i ], ".mp3" ) > 0 ) {
  91.                 formatex ( path, charsmax ( path ), "sound/%s", g_ct_win_sounds [ i ] );
  92.                 precache_generic ( path );
  93.             }
  94.         }
  95.        
  96.         for ( i = 0; i < sizeof g_te_win_sounds; i++ )
  97.         {
  98.             if ( contain ( g_te_win_sounds [ i ], ".wav" ) > 0 ) {
  99.                 precache_sound ( g_te_win_sounds [ i ] );
  100.             }
  101.             else if ( contain ( g_te_win_sounds [ i ], ".mp3" ) > 0 ) {
  102.                 formatex ( path, charsmax ( path ), "sound/%s", g_te_win_sounds [ i ] );
  103.                 precache_generic ( path );
  104.             }
  105.         }
  106.     }
  107. }
  108.  
  109. public plugin_init ( )
  110. {
  111.     register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
  112.    
  113.     register_message ( get_user_msgid ( "SendAudio" ), "FunC_MSG_SendAudio" );
  114. }
  115.  
  116. public FunC_MSG_SendAudio ( msgid, dest, id )
  117. {
  118.     static audiocode [ 26 ];
  119.     get_msg_arg_string ( 2, audiocode, charsmax ( audiocode ) );
  120.    
  121.     if( get_pcvar_num ( pCvar_beginsound ) )
  122.     {
  123.         if ( equal ( audiocode [ 7 ], "MOVEOUT" ) || equal ( audiocode [ 7 ], "LOCKNLOAD" )
  124.         || equal ( audiocode [ 7 ], "LETSGO" )  || ( equal ( audiocode [ 7 ], "GO" ) && !g_radiofix ) )
  125.         {
  126.             set_msg_arg_string ( 2, "%!MRAD_ELIM" ), g_radiofix = false;
  127.             g_radiofix = false;
  128.             new i = random ( sizeof ( g_begun_sounds ) );
  129.             PlaySoundToClients ( g_begun_sounds [ i ] );
  130.             return 1;
  131.         }
  132.     }
  133.     if ( equal ( audiocode [ 7 ], "terwin" ) && get_pcvar_num ( pCvar_endsound ) )
  134.     {
  135.         new i = random ( sizeof ( g_te_win_sounds ) );
  136.         PlaySoundToClients ( g_te_win_sounds [ i ] );
  137.         return 1;
  138.     }
  139.     else if ( equal ( audiocode [ 7 ], "ctwin" ) )
  140.     {
  141.         new i = random ( sizeof ( g_ct_win_sounds ) );
  142.         PlaySoundToClients ( g_ct_win_sounds [ i ] );
  143.         return 1;
  144.     }
  145.     return 0;
  146. }
  147.  
  148. public cmd_fixradio ( ) {
  149.     g_radiofix = true;
  150. }
  151.    
  152. PlaySoundToClients ( const sound [ ] )
  153. {
  154.     if ( equal ( sound [ strlen ( sound ) -4 ], ".mp3" ) )
  155.         client_cmd ( 0, "mp3 play ^"sound/%s^"", sound );
  156.     else
  157.         client_cmd ( 0, "spk ^"%s^"", sound );
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement