Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #define PLUGIN_NAME "UFPS classic/gg Changer"
- #define PLUGIN_VERSION "1.2"
- #define PLUGIN_AUTHOR "UFPS.Team/stalin_alex"
- #define MODE_NORM 0
- #define MODE_GG 1
- #define TASK_DELAY 1625
- #define TASK_STOPGG 1626
- #define STOP_DELAY 120.0
- new g_mode
- new g_menuid
- new g_timecount
- new g_votecount_no
- new g_votecount_yes
- new pcv_delay
- new pcv_ratio
- new pcv_notify
- public plugin_init( )
- {
- register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR )
- register_dictionary( "ggcchanger.txt" )
- register_clcmd( "say /gg", "cmd_say_gg" )
- register_clcmd( "say_team /gg", "cmd_say_gg" )
- register_clcmd( "say /norm", "cmd_say_norm" )
- register_clcmd( "say_team /norm", "cmd_say_norm" )
- pcv_delay = register_cvar( "gg_vote_delay", "180" )
- pcv_ratio = register_cvar( "gg_vote_ratio", "0.6" )
- pcv_notify = register_cvar( "gg_vote_notify", "1" )
- register_cvar ( "amx_show_activity", "0" )
- }
- public plugin_cfg()
- {
- new configsdir[64], filename[64], file
- get_configsdir( configsdir, charsmax( configsdir ) )
- formatex( filename, charsmax( filename ), "%s/gg_maps.ini", configsdir )
- file = fopen( filename, "r" )
- g_mode = MODE_NORM
- if( file )
- {
- new string[64], mapname[32], map[32]
- get_mapname( mapname, charsmax( mapname ) )
- while( !feof( file ) )
- {
- fgets( file, string, charsmax( string ) )
- if( string[0] != ';' && string[0] != '/' && parse( string, map, charsmax( map ) ) && equali ( mapname, map ) )
- {
- g_mode = MODE_GG
- //server_cmd( "ggabort" )
- //set_task( 5.0, "task_pause_umm" )
- break
- }
- }
- fclose( file )
- }
- else
- {
- log_amx( "File ^"%s^" not found", filename )
- }
- g_menuid = menu_create( "GGC_CHANGER_MENU", "_handle_menu", 1 )
- menu_additem( g_menuid, "", "1" )
- menu_additem( g_menuid, "", "2" )
- menu_setprop( g_menuid, MPROP_NUMBER_COLOR, "\r" )
- menu_setprop( g_menuid, MPROP_EXIT, MEXIT_NEVER )
- }
- /*
- public task_pause_umm( )
- {
- cmd_pause_plugin( "umm.amxx" )
- }
- */
- public task_delay( )
- {
- if( get_pcvar_num( pcv_notify ) )
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_ENABLE" )
- return PLUGIN_CONTINUE
- }
- public client_putinserver( id )
- {
- if( !is_user_bot( id ) && !is_user_hltv( id ) )
- {
- if( task_exists( TASK_STOPGG ) ) remove_task( TASK_STOPGG )
- set_task( 13.0, "task_gg_notify", id )
- }
- }
- public task_gg_notify( id )
- {
- if( is_user_connected( id ) && get_pcvar_num( pcv_notify ) )
- {
- switch( g_mode )
- {
- case MODE_GG:
- client_print( id, print_chat, "%L", id, "GGC_VOTE_NORM" )
- case MODE_NORM:
- client_print( id, print_chat, "%L", id, "GGC_VOTE_GG" )
- }
- }
- }
- public client_disconnected( id )
- {
- if( task_exists( id ) ) remove_task ( id )
- if( g_mode == MODE_GG )
- {
- static players[32], num
- get_players ( players, num, "ch" )
- log_to_file("ggcchanger.log", "игрок отключен количество игроков= %d ", num-1)
- if( num == 2)
- {
- set_task( STOP_DELAY, "task_stop_gg", TASK_STOPGG )
- //log_to_file("ggcchanger.log", "количество игроков = 1 через 2 минуты вызываем gg_abort")
- }
- }
- }
- public cmd_say_norm( id )
- {
- if( g_mode == MODE_NORM )
- client_print( id, print_chat, "%L", id, "GGC_ONLY_GG" )
- else if( task_exists( TASK_DELAY ) )
- client_print( id, print_chat, "%L", id, "GGC_VOTE_DISABLE" )
- else
- set_task( 0.1, "_print_menu", id )
- return PLUGIN_HANDLED
- }
- public cmd_say_gg( id )
- {
- if( g_mode == MODE_GG )
- client_print( id, print_chat, "%L", id, "GGC_ONLY_NORM" )
- else if( task_exists( TASK_DELAY ) )
- client_print( id, print_chat, "%L", id, "GGC_VOTE_DISABLE" )
- else
- set_task( 0.1, "_print_menu", id )
- return PLUGIN_HANDLED
- }
- public _print_menu( id )
- {
- if( !is_user_connected( id ) || task_exists( TASK_DELAY ) )
- return PLUGIN_HANDLED
- static m_title[256], m_no[32], m_yes[32]
- static players[32], player, num, i
- get_players ( players, num, "ch" )
- for( i = 0; i < num; ++i )
- {
- player = players[i]
- if( is_user_connected( player ) )
- {
- switch( g_mode )
- {
- case MODE_GG:
- formatex( m_title, charsmax( m_title ), "%L", player, "GGC_MENU_TITLE_NORM" )
- case MODE_NORM:
- formatex( m_title, charsmax( m_title ), "%L", player, "GGC_MENU_TITLE_GG" )
- }
- formatex( m_no, charsmax( m_no ), "%L", player, "GGC_MENU_NO" )
- formatex( m_yes, charsmax( m_yes ), "%L", player, "GGC_MENU_YES" )
- menu_item_setname( g_menuid, 0, m_no )
- menu_item_setname( g_menuid, 1, m_yes )
- menu_setprop( g_menuid, MPROP_TITLE, m_title )
- menu_display( player, g_menuid )
- }
- }
- g_votecount_no = 0
- g_votecount_yes = 0
- set_task( 10.0, "task_close_menu" )
- set_task( float( clamp( get_pcvar_num( pcv_delay ), 60, 3600 ) ), "task_delay", TASK_DELAY )
- return PLUGIN_CONTINUE
- }
- public _handle_menu( id, menu, item )
- {
- if( item == MENU_EXIT ) return PLUGIN_HANDLED
- static name[32], _access, info[3], callback, key
- menu_item_getinfo( menu, item, _access, info, charsmax( info ), _, _, callback )
- key = str_to_num( info )
- get_user_name( id, name, charsmax( name ) )
- switch( key )
- {
- case 1:
- {
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_NO", name )
- g_votecount_no++
- }
- case 2:
- {
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_YES", name )
- g_votecount_yes++
- }
- }
- return PLUGIN_HANDLED
- }
- public task_close_menu( )
- {
- static players[32], player, num, i
- get_players ( players, num, "ch" )
- for( i = 0; i < num; ++i )
- {
- player = players[i]
- if( is_user_connected( player ) )
- {
- menu_cancel( player )
- show_menu( player, 0, "^n" )
- }
- }
- new Float:voteresult, votecount = g_votecount_no + g_votecount_yes
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_COUNT", g_votecount_no, g_votecount_yes )
- if( votecount ) voteresult = float( g_votecount_yes ) / float( votecount )
- if ( voteresult >= get_pcvar_float ( pcv_ratio ) )
- {
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_RESULT_YES" )
- if( g_mode == MODE_GG )
- {
- task_stop_gg
- }
- else
- {
- g_timecount = 10
- set_task( 1.0, "task_start_gg" )
- }
- }
- else
- client_print( 0, print_chat, "%L", LANG_PLAYER, "GGC_VOTE_RESULT_NO" )
- }
- public task_stop_gg( )
- {
- server_cmd( "sv_restart 1" )
- log_to_file("ggcchanger.log", "делаем рестарт")
- //server_cmd( "ggabort" )
- log_to_file("ggcchanger.log", "вызываем gg_abort")
- server_exec()
- set_task( 2.0, "task_start_norm" )
- log_to_file("ggcchanger.log", "запускаем режим Classic")
- }
- public task_start_gg( )
- {
- /*set_cvar_string("sv_password", "")
- log_to_file("ggcchanger.log", "убераем пароль")
- cmd_unpause_plugin( "umm.amxx" )
- log_to_file("cwchanger.log", "запускаем плагин umm")
- server_cmd( "mp_maxrounds 0" )
- server_cmd( "mp_winlimit 0" )
- server_cmd( "mp_timelimit 1" )
- server_cmd( "umm_lastminute 1" )
- server_cmd( "umm_extend_timelimit_max 0" )
- server_cmd( "umm_extend_maxrounds_max 0" )*/
- server_cmd( "mapm_startvote" )
- log_to_file("ggcchanger.log", "запускаем голосование на выбор карты")
- server_exec()
- /*if( find_plugin_byfile( "umm.amxx" ) != INVALID_PLUGIN_ID )
- {
- server_print( "UMM Found" )
- if( callfunc_begin( "check_vote_start", "umm.amxx" ) == 1 )
- {
- server_print( "UMM Vote Start" )
- callfunc_end( )
- }
- }*/
- }
- public task_start_norm( )
- {
- if( g_timecount > 0 )
- {
- client_print( 0, print_center, "%L", LANG_PLAYER, "GGC_COUNTER", --g_timecount )
- set_task( 1.0, "task_start_gg" )
- }
- else
- {
- server_cmd( "changelevel de_dust2_2x2" )
- }
- }
- stock cmd_pause_plugin ( arg[32] )
- {
- new len = strlen ( arg )
- if ( len && ( ( cmd_find_plugin ( arg, len ) ) != -1 ) && pause ( "ac", arg ) )
- {
- log_amx ( "%L", LANG_SERVER, "GGC_PLUGIN_STOP", arg )
- }
- }
- stock cmd_unpause_plugin ( arg[32] )
- {
- new len = strlen ( arg )
- if ( len && ( ( cmd_find_plugin ( arg, len ) ) != -1 ) && unpause ( "ac", arg ) )
- {
- log_amx ( "%L", LANG_SERVER, "GGC_PLUGIN_START", arg )
- }
- }
- stock cmd_find_plugin ( arg[32], &len )
- {
- new name[32], title[32], status[2]
- new pluginsnum = get_pluginsnum()
- for ( new i = 0; i < pluginsnum; ++i )
- {
- get_plugin ( i, name, sizeof ( name ) - 1, title, sizeof ( title ) - 1, status, 0, status, 0, status, 1 )
- if ( equali ( name, arg, len ) && (
- status[0] == 'r' || /*running*/
- status[0] == 'p' || /*paused*/
- status[0] == 's' || /*stopped*/
- status[0] == 'd' /*debug*/
- )
- )
- {
- len = copy ( arg, sizeof ( arg ) - 1, name )
- return i
- }
- }
- return -1
- }
- public plugin_end( )
- {
- if( g_mode == MODE_GG ) //server_cmd( "ggabort" )
- menu_destroy( g_menuid )
- if( task_exists( TASK_DELAY ) ) remove_task( TASK_DELAY )
- if( task_exists( TASK_STOPGG ) ) remove_task( TASK_STOPGG )
- for( new id = 1; id < 33; id++ )
- {
- if( task_exists( id ) ) remove_task( id )
- }
- }
- /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
- *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement