Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.22 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN_NAME "UFPS classic/gg Changer"
  5. #define PLUGIN_VERSION "1.2"
  6. #define PLUGIN_AUTHOR "UFPS.Team/stalin_alex"
  7.  
  8. #define MODE_NORM 0
  9. #define MODE_GG 1
  10. #define TASK_DELAY 1625
  11. #define TASK_STOPGG 1626
  12. #define STOP_DELAY 120.0
  13.  
  14. new g_mode
  15. new g_menuid
  16. new g_timecount
  17. new g_votecount_no
  18. new g_votecount_yes
  19.  
  20. new pcv_delay
  21. new pcv_ratio
  22. new pcv_notify
  23.  
  24. public plugin_init( )
  25. {
  26. register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
  27. register_dictionary( "ggcchanger.txt" )
  28.  
  29. register_clcmd( "say /gg", "cmd_say_gg" )
  30. register_clcmd( "say_team /gg", "cmd_say_gg" )
  31. register_clcmd( "say /norm", "cmd_say_norm" )
  32. register_clcmd( "say_team /norm", "cmd_say_norm" )
  33.  
  34. pcv_delay = register_cvar( "gg_vote_delay", "180" )
  35. pcv_ratio = register_cvar( "gg_vote_ratio", "0.6" )
  36. pcv_notify = register_cvar( "gg_vote_notify", "1" )
  37.  
  38. register_cvar ( "amx_show_activity", "0" )
  39. }
  40.  
  41. public plugin_cfg()
  42. {
  43. new configsdir[64], filename[64], file
  44. get_configsdir( configsdir, charsmax( configsdir ) )
  45. formatex( filename, charsmax( filename ), "%s/gg_maps.ini", configsdir )
  46.  
  47. file = fopen( filename, "r" )
  48.  
  49. g_mode = MODE_NORM
  50.  
  51. if( file )
  52. {
  53. new string[64], mapname[32], map[32]
  54.  
  55. get_mapname( mapname, charsmax( mapname ) )
  56.  
  57. while( !feof( file ) )
  58. {
  59. fgets( file, string, charsmax( string ) )
  60.  
  61. if( string[0] != ';' && string[0] != '/' && parse( string, map, charsmax( map ) ) && equali ( mapname, map ) )
  62. {
  63. g_mode = MODE_GG
  64. //server_cmd( "ggabort" )
  65. //set_task( 5.0, "task_pause_umm" )
  66. break
  67. }
  68. }
  69.  
  70. fclose( file )
  71. }
  72.  
  73. else
  74. {
  75. log_amx( "File ^"%s^" not found", filename )
  76. }
  77.  
  78. g_menuid = menu_create( "GGC_CHANGER_MENU", "_handle_menu", 1 )
  79. menu_additem( g_menuid, "", "1" )
  80. menu_additem( g_menuid, "", "2" )
  81. menu_setprop( g_menuid, MPROP_NUMBER_COLOR, "\r" )
  82. menu_setprop( g_menuid, MPROP_EXIT, MEXIT_NEVER )
  83. }
  84. /*
  85. public task_pause_umm( )
  86. {
  87. cmd_pause_plugin( "umm.amxx" )
  88. }
  89. */
  90. public task_delay( )
  91. {
  92. if( get_pcvar_num( pcv_notify ) )
  93. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_ENABLE" )
  94.  
  95. return PLUGIN_CONTINUE
  96. }
  97.  
  98. public client_putinserver( id )
  99. {
  100. if( !is_user_bot( id ) && !is_user_hltv( id ) )
  101. {
  102. if( task_exists( TASK_STOPGG ) ) remove_task( TASK_STOPGG )
  103.  
  104. set_task( 13.0, "task_gg_notify", id )
  105. }
  106. }
  107.  
  108. public task_gg_notify( id )
  109. {
  110. if( is_user_connected( id ) && get_pcvar_num( pcv_notify ) )
  111. {
  112. switch( g_mode )
  113. {
  114. case MODE_GG:
  115. client_print( id, print_chat, "%L", id, "GGC_VOTE_NORM" )
  116. case MODE_NORM:
  117. client_print( id, print_chat, "%L", id, "GGC_VOTE_GG" )
  118. }
  119. }
  120. }
  121.  
  122. public client_disconnected( id )
  123. {
  124. if( task_exists( id ) ) remove_task ( id )
  125. if( g_mode == MODE_GG )
  126. {
  127. static players[32], num
  128. get_players ( players, num, "ch" )
  129. log_to_file("ggcchanger.log", "игрок отключен количество игроков= %d ", num-1)
  130. if( num == 2)
  131. {
  132. set_task( STOP_DELAY, "task_stop_gg", TASK_STOPGG )
  133. //log_to_file("ggcchanger.log", "количество игроков = 1 через 2 минуты вызываем gg_abort")
  134. }
  135. }
  136. }
  137.  
  138. public cmd_say_norm( id )
  139. {
  140. if( g_mode == MODE_NORM )
  141. client_print( id, print_chat, "%L", id, "GGC_ONLY_GG" )
  142.  
  143. else if( task_exists( TASK_DELAY ) )
  144. client_print( id, print_chat, "%L", id, "GGC_VOTE_DISABLE" )
  145.  
  146. else
  147. set_task( 0.1, "_print_menu", id )
  148.  
  149. return PLUGIN_HANDLED
  150. }
  151.  
  152. public cmd_say_gg( id )
  153. {
  154. if( g_mode == MODE_GG )
  155. client_print( id, print_chat, "%L", id, "GGC_ONLY_NORM" )
  156.  
  157. else if( task_exists( TASK_DELAY ) )
  158. client_print( id, print_chat, "%L", id, "GGC_VOTE_DISABLE" )
  159.  
  160. else
  161. set_task( 0.1, "_print_menu", id )
  162.  
  163. return PLUGIN_HANDLED
  164. }
  165.  
  166. public _print_menu( id )
  167. {
  168. if( !is_user_connected( id ) || task_exists( TASK_DELAY ) )
  169. return PLUGIN_HANDLED
  170.  
  171. static m_title[256], m_no[32], m_yes[32]
  172.  
  173. static players[32], player, num, i
  174. get_players ( players, num, "ch" )
  175.  
  176. for( i = 0; i < num; ++i )
  177. {
  178. player = players[i]
  179.  
  180. if( is_user_connected( player ) )
  181. {
  182. switch( g_mode )
  183. {
  184. case MODE_GG:
  185. formatex( m_title, charsmax( m_title ), "%L", player, "GGC_MENU_TITLE_NORM" )
  186. case MODE_NORM:
  187. formatex( m_title, charsmax( m_title ), "%L", player, "GGC_MENU_TITLE_GG" )
  188. }
  189.  
  190. formatex( m_no, charsmax( m_no ), "%L", player, "GGC_MENU_NO" )
  191. formatex( m_yes, charsmax( m_yes ), "%L", player, "GGC_MENU_YES" )
  192.  
  193. menu_item_setname( g_menuid, 0, m_no )
  194. menu_item_setname( g_menuid, 1, m_yes )
  195.  
  196. menu_setprop( g_menuid, MPROP_TITLE, m_title )
  197. menu_display( player, g_menuid )
  198. }
  199. }
  200.  
  201. g_votecount_no = 0
  202. g_votecount_yes = 0
  203.  
  204. set_task( 10.0, "task_close_menu" )
  205. set_task( float( clamp( get_pcvar_num( pcv_delay ), 60, 3600 ) ), "task_delay", TASK_DELAY )
  206.  
  207. return PLUGIN_CONTINUE
  208. }
  209.  
  210. public _handle_menu( id, menu, item )
  211. {
  212. if( item == MENU_EXIT ) return PLUGIN_HANDLED
  213.  
  214. static name[32], _access, info[3], callback, key
  215. menu_item_getinfo( menu, item, _access, info, charsmax( info ), _, _, callback )
  216.  
  217. key = str_to_num( info )
  218.  
  219. get_user_name( id, name, charsmax( name ) )
  220.  
  221. switch( key )
  222. {
  223. case 1:
  224. {
  225. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_NO", name )
  226. g_votecount_no++
  227. }
  228.  
  229. case 2:
  230. {
  231. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_YES", name )
  232. g_votecount_yes++
  233. }
  234. }
  235.  
  236. return PLUGIN_HANDLED
  237. }
  238.  
  239. public task_close_menu( )
  240. {
  241. static players[32], player, num, i
  242. get_players ( players, num, "ch" )
  243.  
  244. for( i = 0; i < num; ++i )
  245. {
  246. player = players[i]
  247.  
  248. if( is_user_connected( player ) )
  249. {
  250. menu_cancel( player )
  251. show_menu( player, 0, "^n" )
  252. }
  253. }
  254.  
  255. new Float:voteresult, votecount = g_votecount_no + g_votecount_yes
  256.  
  257. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_COUNT", g_votecount_no, g_votecount_yes )
  258.  
  259. if( votecount ) voteresult = float( g_votecount_yes ) / float( votecount )
  260.  
  261. if ( voteresult >= get_pcvar_float ( pcv_ratio ) )
  262. {
  263. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_RESULT_YES" )
  264.  
  265. if( g_mode == MODE_GG )
  266. {
  267. task_stop_gg
  268. }
  269.  
  270. else
  271. {
  272. g_timecount = 10
  273. set_task( 1.0, "task_start_gg" )
  274. }
  275. }
  276.  
  277. else
  278. client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_RESULT_NO" )
  279. }
  280.  
  281. public task_stop_gg( )
  282. {
  283. server_cmd( "sv_restart 1" )
  284. log_to_file("ggcchanger.log", "делаем рестарт")
  285. //server_cmd( "ggabort" )
  286. log_to_file("ggcchanger.log", "вызываем gg_abort")
  287. server_exec()
  288. set_task( 2.0, "task_start_norm" )
  289. log_to_file("ggcchanger.log", "запускаем режим Classic")
  290.  
  291. }
  292.  
  293. public task_start_gg( )
  294. {
  295. /*set_cvar_string("sv_password", "")
  296. log_to_file("ggcchanger.log", "убераем пароль")
  297. cmd_unpause_plugin( "umm.amxx" )
  298. log_to_file("cwchanger.log", "запускаем плагин umm")
  299. server_cmd( "mp_maxrounds 0" )
  300. server_cmd( "mp_winlimit 0" )
  301. server_cmd( "mp_timelimit 1" )
  302. server_cmd( "umm_lastminute 1" )
  303. server_cmd( "umm_extend_timelimit_max 0" )
  304. server_cmd( "umm_extend_maxrounds_max 0" )*/
  305. server_cmd( "mapm_startvote" )
  306. log_to_file("ggcchanger.log", "запускаем голосование на выбор карты")
  307. server_exec()
  308.  
  309. /*if( find_plugin_byfile( "umm.amxx" ) != INVALID_PLUGIN_ID )
  310. {
  311. server_print( "UMM Found" )
  312. if( callfunc_begin( "check_vote_start", "umm.amxx" ) == 1 )
  313. {
  314. server_print( "UMM Vote Start" )
  315. callfunc_end( )
  316. }
  317. }*/
  318. }
  319.  
  320. public task_start_norm( )
  321. {
  322. if( g_timecount > 0 )
  323. {
  324. client_print( 0, print_center, "%L", LANG_PLAYER, "GGC_COUNTER", --g_timecount )
  325. set_task( 1.0, "task_start_gg" )
  326. }
  327.  
  328. else
  329. {
  330. server_cmd( "changelevel de_dust2_2x2" )
  331. }
  332. }
  333.  
  334. stock cmd_pause_plugin ( arg[32] )
  335. {
  336. new len = strlen ( arg )
  337.  
  338. if ( len && ( ( cmd_find_plugin ( arg, len ) ) != -1 ) && pause ( "ac", arg ) )
  339. {
  340. log_amx ( "%L", LANG_SERVER, "GGC_PLUGIN_STOP", arg )
  341. }
  342. }
  343.  
  344. stock cmd_unpause_plugin ( arg[32] )
  345. {
  346. new len = strlen ( arg )
  347.  
  348. if ( len && ( ( cmd_find_plugin ( arg, len ) ) != -1 ) && unpause ( "ac", arg ) )
  349. {
  350. log_amx ( "%L", LANG_SERVER, "GGC_PLUGIN_START", arg )
  351. }
  352. }
  353.  
  354. stock cmd_find_plugin ( arg[32], &len )
  355. {
  356. new name[32], title[32], status[2]
  357. new pluginsnum = get_pluginsnum()
  358.  
  359. for ( new i = 0; i < pluginsnum; ++i )
  360. {
  361. get_plugin ( i, name, sizeof ( name ) - 1, title, sizeof ( title ) - 1, status, 0, status, 0, status, 1 )
  362.  
  363. if ( equali ( name, arg, len ) && (
  364. status[0] == 'r' || /*running*/
  365. status[0] == 'p' || /*paused*/
  366. status[0] == 's' || /*stopped*/
  367. status[0] == 'd' /*debug*/
  368. )
  369. )
  370. {
  371. len = copy ( arg, sizeof ( arg ) - 1, name )
  372.  
  373. return i
  374. }
  375. }
  376.  
  377. return -1
  378. }
  379.  
  380. public plugin_end( )
  381. {
  382. if( g_mode == MODE_GG ) //server_cmd( "ggabort" )
  383.  
  384. menu_destroy( g_menuid )
  385.  
  386. if( task_exists( TASK_DELAY ) ) remove_task( TASK_DELAY )
  387. if( task_exists( TASK_STOPGG ) ) remove_task( TASK_STOPGG )
  388.  
  389. for( new id = 1; id < 33; id++ )
  390. {
  391. if( task_exists( id ) ) remove_task( id )
  392. }
  393. }
  394. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  395. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  396. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement