HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2.  
  3. new const g_sPrefix[ ] = "RoundEndSounds"
  4.  
  5. enum _:eMusicInfos { sName[ 128 ], sSound[ 64 ] };
  6.  
  7. new Array: g_daSounds, g_iData[ eMusicInfos ];
  8. new g_iSoundsNum, g_iPrevSound = -1, bool: g_bEnabled[ 33 ];
  9.  
  10. public plugin_init( )
  11. {
  12. register_plugin( "Round End Sounds", "1.0", "Demon" );
  13.  
  14. if ( g_iSoundsNum > 0 )
  15. {
  16. register_event( "SendAudio", "PlayMusic", "a", "2&%!MRAD_ctwin" );
  17. register_event( "SendAudio", "PlayMusic", "a", "2&%!MRAD_terwin" );
  18.  
  19. register_clcmd( "say /korvegi", "Toggle" );
  20.  
  21. set_task( 150.0, "Advertising", 98765, _, _, "b" );
  22. }
  23. }
  24.  
  25. public PlayMusic( )
  26. {
  27. static iRand;
  28.  
  29. do iRand = random( g_iSoundsNum );
  30. while ( iRand == g_iPrevSound );
  31.  
  32. ArrayGetArray( g_daSounds, iRand, g_iData );
  33.  
  34. ChatColor( 0, g_iData[ sSound ], "Zene:^3 %s", g_iData[ sName ] );
  35.  
  36. g_iPrevSound = iRand;
  37. }
  38.  
  39. public plugin_precache( )
  40. {
  41. new pFile = fopen( "addons/amxmodx/configs/musiclist.ini", "rt" );
  42.  
  43. g_daSounds = ArrayCreate( eMusicInfos );
  44.  
  45. if ( pFile )
  46. {
  47. new sLine[ 200 ];
  48.  
  49. while ( !feof( pFile ) )
  50. {
  51. fgets( pFile, sLine, charsmax( sLine ) );
  52. if ( sLine[0] == ';' || strlen( sLine ) < 5 ) continue;
  53.  
  54. parse( sLine, g_iData[ sName ], charsmax( g_iData[ sName ] ), g_iData[ sSound ], charsmax( g_iData[ sSound ] ) );
  55.  
  56. if ( ( contain( g_iData[ sSound ], ".mp3" ) == -1 ) && ( contain( g_iData[ sSound ], ".wav" ) == -1 ) ) continue;
  57.  
  58. if( strlen( g_iData[ sName ] ) == 0 ) g_iData[ sName ] = "Ismeretlen";
  59.  
  60. ArrayPushArray( g_daSounds, g_iData );
  61. precache_sound( g_iData[ sSound ] );
  62. }
  63. fclose( pFile );
  64. }
  65.  
  66. g_iSoundsNum = ArraySize( g_daSounds );
  67. log_amx( "Round End Sounds" );
  68. log_amx( "%d loaded music.", g_iSoundsNum );
  69. }
  70.  
  71. public Advertising( ) { ChatColor( 0, "", "Körvégi zenék Ki/Be kapcsolásához:^3 /korvegi^1 ." ); }
  72.  
  73. public Toggle( iId ) { ChatColor( iId, "", "^3%skapcsoltad^1 a körvégi zenéket!", ( g_bEnabled[ iId ] ^= true ) ? "Be" : "Ki" ); }
  74.  
  75. public client_putinserver( iId ) { g_bEnabled[ iId ] = true; }
  76.  
  77. public plugin_end( ) { ArrayDestroy( g_daSounds ); }
  78.  
  79. stock ChatColor( const iId, sMusic[ ], const sMessage[ ], any:... )
  80. {
  81. static iPlrNum, iPlayers[32], sMsg[ 256 ], iIdMsg, bool: bPlay;
  82.  
  83. vformat( sMsg, charsmax( sMsg ), sMessage, 4 );
  84. format( sMsg, charsmax( sMsg ), "^4[%s]^1 %s", g_sPrefix, sMsg );
  85.  
  86. if ( !iIdMsg ) iIdMsg = get_user_msgid( "SayText" );
  87.  
  88. if ( iId )
  89. {
  90. if( !is_user_connected( iId ) ) return;
  91. iPlayers[ 0 ] = iId;
  92. iPlrNum = 1;
  93. }
  94. else get_players( iPlayers, iPlrNum, "ch" );
  95.  
  96. if ( ( bPlay = strlen( sMusic ) > 0 ) ) format( sMusic, 63, "%s sound/%s", ( contain( sMusic, ".mp3" ) != -1 ) ? "mp3 play" : "spk", sMusic );
  97.  
  98. for ( new i, iPId; i < iPlrNum; ++i )
  99. {
  100. iPId = iPlayers[ i ];
  101. if ( bPlay )
  102. {
  103. if ( !g_bEnabled[ iPId ] ) continue;
  104. client_cmd( iPId, "%s", sMusic );
  105. }
  106.  
  107. message_begin( MSG_ONE, iIdMsg, _, iPId );
  108. write_byte( iPId );
  109. write_string( sMsg );
  110. message_end( );
  111. }
  112. }
  113. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  114. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  115. */
  116.