HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include < amxmodx >
  2. #include < amxmisc >
  3.  
  4. new szSound [ 32 + 1 ][ 63 + 1 ],
  5. Sound [ 33 ], lens, r_num = 0
  6.  
  7. public plugin_init ( )
  8. {
  9. register_plugin ( "Round End", "1.0", "OverGame" )
  10.  
  11. register_cvar ( "re_info", "1" )
  12. register_cvar ( "re_start_off", "0" )
  13.  
  14. register_logevent ( "logevent_round_start", 2, "1=Round_Start" )
  15. register_logevent ( "logevent_round_end", 2, "1=Round_End" )
  16.  
  17. register_clcmd ( "say /korvegi", "volume_control" )
  18. register_clcmd ( "say_team /korvegi", "volume_control" )
  19.  
  20. set_task ( 600.0, "control_info", _, _, _, "b" )
  21. register_dictionary ( "round_end.txt" )
  22. }
  23.  
  24. public plugin_precache ( )
  25. {
  26. read_ini ( )
  27.  
  28. new i
  29. for ( i = 1; i <= lens; i++ )
  30. precache_sound ( szSound [ i ] )
  31. }
  32.  
  33. public plugin_cfg ( )
  34. {
  35. new szCfgDir [ 64 ], szFile [ 192 ]
  36. get_configsdir ( szCfgDir, charsmax ( szCfgDir ) )
  37. format ( szFile, charsmax ( szFile ), "%s/round_end.cfg", szCfgDir )
  38.  
  39. if ( file_exists ( szFile ) )
  40. server_cmd ( "exec %s", szFile )
  41. }
  42.  
  43. public read_ini ( )
  44. {
  45. new len = 1, buffer [ 256 ]
  46. new file = fopen ( "/addons/amxmodx/configs/round_end.ini", "r" )
  47.  
  48. while ( !feof ( file ) )
  49. {
  50. fgets ( file, buffer, 255 )
  51. trim ( buffer )
  52.  
  53. if ( buffer [ 0 ] == '"' )
  54. {
  55. parse ( buffer, szSound [ len ], 63 )
  56. } else {
  57. continue
  58. }
  59. len++
  60. }
  61.  
  62. lens = len - 1
  63. fclose ( file )
  64. }
  65.  
  66. public logevent_round_start ( )
  67. {
  68. for ( new id = 1; id <= get_maxplayers (); id++ )
  69. {
  70. if ( get_cvar_num ( "re_start_off" ) )
  71. client_cmd ( id, "mp3 stop" )
  72. }
  73.  
  74. return PLUGIN_CONTINUE
  75. }
  76.  
  77. public logevent_round_end ( )
  78. {
  79. if ( r_num == lens )
  80. r_num = 0
  81.  
  82. r_num++
  83.  
  84. for ( new id = 1; id <= get_maxplayers (); id++ )
  85. {
  86. if ( is_user_connected ( id ) && Sound [ id ] )
  87. client_cmd ( id, "mp3 play sound/%s", szSound [ r_num ] )
  88. }
  89.  
  90. return PLUGIN_CONTINUE
  91. }
  92.  
  93. public client_putinserver ( id )
  94. Sound [ id ] = true
  95.  
  96. public control_info ( )
  97. {
  98. for ( new id = 1; id <= get_maxplayers (); id++ )
  99. {
  100. if ( is_user_connected ( id ) && get_cvar_num ( "re_info" ) )
  101. {
  102. ShowMsg ( id, "%L %L", LANG_SERVER, "RE_PREFIX", LANG_SERVER, "RE_INFO" )
  103. }
  104. }
  105.  
  106. return PLUGIN_CONTINUE
  107. }
  108.  
  109. public volume_control ( id )
  110. {
  111. if ( Sound [ id ] )
  112. {
  113. Sound [ id ] = false
  114. ShowMsg ( id, "%L %L", LANG_SERVER, "RE_PREFIX", LANG_SERVER, "RE_OFF" )
  115. } else {
  116. Sound [ id ] = true
  117. ShowMsg ( id, "%L %L", LANG_SERVER, "RE_PREFIX", LANG_SERVER, "RE_ON" )
  118. }
  119.  
  120. return PLUGIN_HANDLED
  121. }
  122.  
  123. stock ShowMsg ( const id, const input [ ], any:... )
  124. {
  125. new count = 1, players [ 32 ]
  126. static msg [ 188 ]
  127. vformat ( msg, 187, input, 3 )
  128.  
  129. replace_all ( msg, 187, "!g", "^4" )
  130. replace_all ( msg, 187, "!y", "^1" )
  131. replace_all ( msg, 187, "!t", "^3" )
  132.  
  133. if ( id ) players [ 0 ] = id; else get_players ( players, count, "ch" )
  134. {
  135. for ( new i = 0; i < count; i++ )
  136. {
  137. if ( is_user_connected ( players [ i ] ) )
  138. {
  139. message_begin ( MSG_ONE_UNRELIABLE, get_user_msgid ( "SayText" ), _, players [ i ] )
  140. write_byte ( players [ i ] )
  141. write_string ( msg )
  142. message_end ( )
  143. }
  144. }
  145. }
  146. }