warning 213: tag mismatch

Статус
В этой теме нельзя размещать новые ответы.
Сообщения
31
Реакции
1
Помог
1 раз(а)
Ошибка
\(296) : warning 213: tag mismatch
\(1501) : warning 213: tag mismatch
\1856) : warning 213: tag mismatch
Компилятор
Локальный
Amx Mod X
1.9.0
Исходный код
get_mapname(curmap,31)
if((strlen(tmp_map)>0) && (strcmp(curmap, tmp_map, 1)!=0)){
set_vaultdata("cw_map", tmp_map)
server_cmd("changelevel %s", tmp_map)
}

// (296) : warning 213: tag mismatch


}
war_setvaults()

new curmap[32]
get_mapname(curmap,31)
if(strcmp(curmap, maps[map_toshow], 1) != 0){
set_vaultdata("cw_map", maps[map_toshow])
server_cmd("changelevel %s",maps[map_toshow])
}
// (1501) : warning 213: tag mismatch



get_mapname(str,31)
format(inifile,63,"%s/maps.ini", cfgdir)
num_maps = 0
map_toshow = -1
if(file_exists(inifile)){
pos = 0
while(read_file(inifile,pos++,tmp,127,len))
if((tmp[0] != ';') && (strlen(tmp) > 1) && (num_maps < maxtagsini)){
copy(maps[num_maps],31,tmp)
if(strcmp(str, maps[num_maps++], 1) == 0) map_toshow = num_maps-1
}

//1856) : warning 213: tag mismatch
\(296) : warning 213: tag mismatch
\(1501) : warning 213: tag mismatch
\1856) : warning 213: tag mismatch
 
В этой теме было размещено решение! Перейти к решению.
Сообщения
141
Реакции
55
Помог
2 раз(а)
The full plugin .sma or source code would be helpful I guess?
 
Сообщения
31
Реакции
1
Помог
1 раз(а)

Вложения

Последнее редактирование:
Сообщения
443
Реакции
319
Помог
13 раз(а)
C++:
#define PLUGIN "x-war"
#define VERSION "1.5"
#define AUTHOR "niro"

// command access level:
#define CMDACCESS ADMIN_LEVEL_A
#define SETTINSMENUACCESS ADMIN_LEVEL_B

//Message ID's
#define MID_ALL        0
#define MID_CT        -1
#define MID_TER        -2
#define MID_SPEC    -3

//Additional ID's:
#define AID_RCHECK    40
#define AID_HINIT    80
#define AID_EHACK    120
#define AID_HREAD    130
#define AID_SRDY    140
#define AID_WHUD    180
#define AID_SS2        220
#define AID_SS3        260

//Task ID's:
#define TID_COUNTDOWN    133331
#define TID_ONLYKNIFE    133332
#define TID_RESTARTS    133333
#define TID_PRESTART    133334
#define TID_HLTVREC    133335
#define TID_MSG        133336
#define TID_STSTIMEOUT    133337

// #define LOG
#define DEBUG
//#define HLTV_SUPPORT
//#define HLTV_ADDDELAY    10
//#define POV_ADDDELAY    10
//#define HLTV_PUBLIC_PORT 27020

#define CLANLEADERTAG    "(cl)"
#define textblock_size    256
#define maxtagsini    64
#define STS_TIMEOUT    30

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <newmenus>

#if defined HLTV_SUPPORT
#include <sockets>
#endif

new t_score[2][3]    // [team1,team2][total,half1,half2]
new status        // 0 = off, 1 = warmup1, 2 = restarts, 3 = knife, 4 = waiting, 5 = restarts, 6 = 1st half, 7 = warmup2,  8 = restarts, 9 = 2nd half
new gametype        // 0 = Maxrounds + 1 (mr), 1 = Maxrounds * 2 (mx)
new maxrounds, period_number
new cfgdir[128], war_password[32], serv_password[32]
new captain_id[2], adminname[32]
new t_name[2][32]
new pl_rec[32], pl_recnum
new whosready[2][256]
new readyplayers[33], p_ready[2], minready
new war_countdowntimer

new gt[2][] = { "mr", "mx" }

new clans[maxtagsini][32],num_clans, clan1_toshow = 0, clan2_toshow = 1
new cfgs[maxtagsini][32], num_cfgs, cfg_toshow = 0
new maps[maxtagsini][32], num_maps, map_toshow = 0
new pwds[maxtagsini][32], num_pwds, pwd_toshow = 0
new menu_sts

#if defined HLTV_SUPPORT
new hltv_id,hltv_ip[16],hltv_port,hltv_pass[32], hltv_rec_delay
new hltv_status        //0 = Not Connected or bad rcon passw, 1 = OK, 2 = Recording
new hltv_address
#endif

//===========================================================================================
//************************************   MAIN   *********************************************
//===========================================================================================
public plugin_init(){
    #if defined DEBUG
    log_amx("* plugin_init()")
    #endif
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("x-war.txt")
    
    register_concmd("cw","war_begin",CMDACCESS,"- Starts a clanmatch")
    register_concmd("cw help","war_begin",CMDACCESS,"- Help message")
    register_concmd("cwstart","war_forcestart",CMDACCESS,"- Starts a warround immediately")
    register_concmd("cwabort","war_abort",CMDACCESS,"- Aborts a clanmatch immediately")
    register_concmd("cwrestart","war_restart",CMDACCESS,"- Restart a clanmatch/half")

    register_event("SendAudio","war_roundend","a","2=%!MRAD_terwin","2=%!MRAD_ctwin")
    register_event("ResetHUD", "war_hudreset", "be")
    register_logevent("war_clchangename", 3, "1=changed name to")
    
    register_cvar("xw_tie", "1")
    register_cvar("xw_screenshots", "0")
    register_cvar("xw_demos", "0")
    #if defined HLTV_SUPPORT
    register_cvar("xw_hltv_passw", "hltvpass")
    register_cvar("xw_hltv_demosdir", "demos\")
    #endif
    register_cvar("xw_swapteams", "1")
    register_cvar("xw_ot_rounds", "3")
    register_cvar("xw_warmup_timelimit", "15")
    register_cvar("xw_restarts", "1 2 2")
    register_cvar("xw_knife_round", "0")
    register_cvar("xw_block_chooseteam", "0")
    register_cvar("xw_onlykillfrags", "0")
    register_cvar("xw_readymenu", "0")
    register_cvar("xw_gag", "1")

    register_cvar("xw_minready", "16")
    register_cvar("xw_gametype", "0")
    register_cvar("xw_maxrounds", "15")
    register_cvar("xw_configs", "default.cfg")
    register_cvar("xw_public_cfg", "server.cfg")

    register_clcmd("say","war_say")
    register_clcmd("say_team","war_sayteam")
    register_clcmd("chooseteam","war_chooseteam")
    register_clcmd("jointeam", "war_chooseteam")
    register_clcmd("cwmenu","war_show_mm",CMDACCESS,"- displays war system menu")

    get_configsdir(cfgdir,63)
    format(cfgdir,63,"%s/x-war",cfgdir)

    server_cmd("exec %s/x-war.cfg",cfgdir)
    #if defined HLTV_SUPPORT
    hltv_status = 0
    hltv_address = -1
    #endif
    new tmp[2]

    get_vaultdata("cw_initialized",tmp,1)
    if(str_to_num(tmp) == 1) set_task(3.0, "war_readvaults")

    return PLUGIN_CONTINUE
}

public war_init(){
    #if defined DEBUG
    log_amx("* war_init()")
    #endif   
    gametype = get_cvar_num("xw_gametype")
    maxrounds = get_cvar_num("xw_maxrounds")
    minready = get_cvar_num("xw_minready")
    t_score[0] = {0, 0, 0}
    t_score[1] = {0, 0, 0}
    period_number = 0
    pl_recnum = 0
    menu_sts = 0
    
    return PLUGIN_CONTINUE
}

public war_begin(id){
    #if defined DEBUG
    log_amx("* war_begin(%d)", id)
    #endif
    if (id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED
    }
    new tmp[32], argc = read_argc()-1

    if(argc > 0){
        read_argv(1,tmp,31)
        if(containi(tmp, "help")==0){
            (id==0) ? war_servertext("clt_info5a") : war_clienttext(id, "clt_info5a")
            return PLUGIN_HANDLED
        }
    }
    if (status > 0){
        (id==0) ? war_servertext("clt_init4") : war_clienttext(id, "clt_init4")
        return PLUGIN_HANDLED
    }
    #if defined HLTV_SUPPORT
    if(hltv_status == 2){
        (id==0) ? war_servertext("clt_info6") : war_clienttext(id, "clt_info6")
        return PLUGIN_HANDLED
    }
    #endif
    new tmp_map[32], curmap[32], str[256], i

    format(t_name[0], 31, "")
    format(t_name[1], 31, "")
    
    for(i=0;i<argc;i++){
        read_argv(i+1,tmp,31)
        #if defined DEBUG
        log_amx("arg%d = %s", i, tmp)
        #endif
        if(is_map_valid(tmp)){
            format(tmp_map,31,"%s",tmp)
            war_add2ini("maps.ini", tmp_map)
            #if defined DEBUG
            log_amx("map is %s", tmp_map)
            #endif
        }
        else if(containi(tmp,"pw=")==0){
            format(war_password,31,"%s",tmp)
            replace(war_password,31,"pw=","")
            war_add2ini("passwords.ini", war_password)
            #if defined DEBUG
            log_amx("war_password is %s", war_password)
            #endif
        }
        else if(containi(tmp,"mr")==0){
            gametype = 0
            set_cvar_num("xw_gametype", gametype)
            replace(tmp,31,"mr","")
            maxrounds = str_to_num(tmp)
            if(maxrounds == 0){
                (id==0) ? war_servertext("clt_info5a") : war_clienttext(id, "clt_info5a")
                return PLUGIN_HANDLED
            }
            set_cvar_num("xw_maxrounds", maxrounds)
            #if defined DEBUG
            log_amx("gametype is %s, maxrounds = %d", gt[gametype], maxrounds)
            #endif
        }
        else if(containi(tmp,"mx")==0){
            gametype = 1
            set_cvar_num("xw_gametype", gametype)
            replace(tmp,31,"mx","")
            maxrounds = str_to_num(tmp)
            if(maxrounds == 0){
                (id==0) ? war_servertext("clt_info5a") : war_clienttext(id, "clt_info5a")
                return PLUGIN_HANDLED
            }
            set_cvar_num("xw_maxrounds", maxrounds)
            #if defined DEBUG
            log_amx("gametype is %s, maxrounds = %d", gt[gametype], maxrounds)
            #endif
        }
        else{
            format(str,255,"%s/cfg/%s.cfg",cfgdir,tmp)
            if(file_exists(str)){
                set_cvar_string("xw_configs", tmp)
                #if defined DEBUG
                log_amx("xw_configs is %s", tmp)
                #endif
            }
            else if(isdigit(tmp[0]) && (strlen(tmp) < 3)){
                new x = str_to_num(tmp)
                if((x > 0) && (x < 11)){
                    minready = str_to_num(tmp)
                    set_cvar_num("xw_minready", minready)
                    #if defined DEBUG
                    log_amx("minready is %d", minready)
                    #endif
                }
                else{
                    (id==0) ? war_servertext("clt_init3") : war_clienttext(id, "clt_init3")
                    return PLUGIN_HANDLED
                }
            }
            else if((i < 2) && (argc>1)){
                format(t_name[i], 31, "%s", tmp)
                war_add2ini("clans.ini", t_name[i])
            }
            else{
                (id==0) ? war_servertext("clt_info5a") : war_clienttext(id, "clt_info5a")
                return PLUGIN_HANDLED
            }
        }
    }
    if((strlen(t_name[0]) + strlen(t_name[1])) == 0){
        clan1_toshow = 0
        clan2_toshow = 1
        war_loadini()
        war_findtags()
        if((clan1_toshow>1) && (clan2_toshow>1)){
            format(t_name[0], 31, "%s", clans[clan1_toshow])
            format(t_name[1], 31, "%s", clans[clan2_toshow])
        }
    }
    status = 1;    set_vaultdata("cw_status", "1")
    #if defined DEBUG
    log_amx("argc = %d", argc)
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    war_init()
    war_setvaults()

    get_mapname(curmap,31);
    if(strlen(tmp_map)>0 && strcmp(curmap, tmp_map, true)){
        set_vaultdata("cw_map", tmp_map)
        server_cmd("changelevel %s", tmp_map)
    }
    war_warmup()
    
    return PLUGIN_HANDLED
}

public war_warmup(){
    #if defined DEBUG
    log_amx("* war_warmup()")
    #endif
    new tmp[256]
    
    war_clearready()
    get_cvar_string("xw_configs",tmp,255)
    replace(tmp,63,".cfg","")
    format(tmp,255,"%s/wmcfg/%s.cfg",cfgdir,tmp)
    if(!file_exists(tmp)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_cfgwrong", tmp)
        #endif
        format(tmp,256,"%s/wmcfg/default.cfg",cfgdir)
    }
    
    server_cmd("exec ^"%s^"",tmp)
    war_rr("1")
    
    set_task(3.3,"war_warmup_hud", MID_ALL)
    
    get_cvar_string("xw_warmup_timelimit",tmp,255)
    war_countdowntimer = str_to_num(tmp)*60
    if(war_countdowntimer > 0) set_task(0.0,"war_countdown", TID_COUNTDOWN)

    #if defined DEBUG
    new players[32],num_players,i
    get_players(players,num_players, "dh")
    for(i=0;i<num_players;i++) set_task(1.0, "war_readycheck", AID_RCHECK + players[i])
    #endif
    
    return PLUGIN_CONTINUE
}

public war_prestart(){
    #if defined DEBUG
    log_amx("* war_prestart(status=%d)", status)
    #if defined HLTV_SUPPORT
    log_amx("* war_prestart(hltv_status=%d)", hltv_status)
    #endif
    #endif
    new str[256], dir[10]
    
    remove_task(TID_COUNTDOWN)
    
    for(new i=1;i<=32;i++) remove_task(AID_SRDY + i)
    
    if((status==1) && (get_cvar_num("xw_knife_round")==1) && (period_number==0)) dir = "knifecfg"
    else if(period_number==0) dir = "cfg"
    else dir = "otcfg"
    
    get_cvar_string("xw_configs",str,255)
    replace(str,255,".cfg","")
    format(str,255,"%s/%s/%s.cfg",cfgdir,dir,str)
    if(!file_exists(str)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_cfgwrong", str)
        #endif
        format(str,255,"%s/%s/default.cfg",cfgdir,dir)
    }
    
    server_cmd("exec ^"%s^"",str)
    war_setpassword()

    set_hudmessage(0,0,0, 0.0,0.0, 0, 1.0, 1.0, 0.2, 0.2, 4)    // remove whos ready msg
    show_hudmessage(0,".")
    
    #if defined DEBUG
    log_amx("cfg is %s", str)
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    num_to_str(status, str, 15)
    set_vaultdata("cw_status",str)

    if(menu_sts){
        menu_destroy(menu_sts)
        menu_sts = 0
    }
    #if defined HLTV_SUPPORT
    if(hltv_status == 1) set_task(float(hltv_rec_delay), "war_hltvrecord", TID_HLTVREC)
    #endif
    war_demo()

    if(captain_id[0]==0) war_setcaptains(0)
    if(captain_id[1]==0) war_setcaptains(1)
    #if defined DEBUG       
    log_amx("CT captain id=%d, T captain id=%d", captain_id[0], captain_id[1])
    #endif
    #if defined LOG
    log_amx("%L", LANG_SERVER, "log_captains", captain_id[0], captain_id[1])
    #endif   

    if((status==1) && (get_cvar_num("xw_knife_round")==1) && (period_number==0)) war_startknife()
    else war_start()
    
    return PLUGIN_CONTINUE
}

public war_startknife(){
    #if defined DEBUG
    log_amx("* war_startknife()")
    #endif
    new x = war_hudtext(MID_ALL,"hud_start3k",10,2,10)
    new str[16], tmp[10], i
    status = 2;    set_vaultdata("cw_status", "2")
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    get_cvar_string("xw_restarts", str, 63)
    while(strlen(str) > 0){
        for(i=0;i<10;i++){
            if(str[i]==' '){tmp[i]=0;break;}
            tmp[i]=str[i]
        }
        replace(str,63,tmp,"")
        replace(str,63," ","")
        set_task(float(x),"war_rr",TID_RESTARTS,tmp,1)
        x+=str_to_num(tmp)
    }
    set_task(float(x+1),"war_knife_msg",TID_MSG)
    set_task(float(x+2),"war_onlyknife",TID_ONLYKNIFE)
    
    return PLUGIN_CONTINUE
}

public war_start(){
    #if defined DEBUG
    log_amx("* war_start()")
    #endif
    new x = war_hudtext(MID_ALL,"hud_start3",10,2,10)
    new str[16], tmp[10], i

    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif   
    status = (status == 1) ? 5 : status + 1
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    num_to_str(status, str, 15)
    set_vaultdata("cw_status",str)
    
    get_cvar_string("xw_restarts", str, 63)
    while(strlen(str) > 0){
        for(i=0;i<10;i++){
            if(str[i]==' '){tmp[i]=0;break;}
            tmp[i]=str[i]
        }
        replace(str,63,tmp,"")
        replace(str,63," ","")
        set_task(float(x),"war_rr",TID_RESTARTS,tmp,1)
        x+=str_to_num(tmp)
    }
    set_task(float(x+1),"war_live_msg",TID_MSG)
    
    return PLUGIN_CONTINUE
}

public war_forcestart(id){
    #if defined DEBUG
    log_amx("* war_forcestart(%d)",id)
    #endif
    if (id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED
    }
    if(status==0){
        (id==0) ? war_servertext("clt_abort") : war_clienttext(id, "clt_abort")
    }
    else if((status == 1) || (status == 7)){
        new players[32], num, i
        
        get_players(players,num,"ch")
        for(i=0;i<num;i++) menu_cancel(players[i])
        set_task(2.0,"war_prestart", TID_PRESTART)
        war_clienttext(id, "clt_start3a")
    }
    else (id==0) ? war_servertext("clt_start3b") : war_clienttext(MID_ALL, "clt_start3b")
    
    return PLUGIN_HANDLED
}

public war_restart(id){
    #if defined DEBUG
    log_amx("* war_restart(%d, argc=%d)",id,read_argc())
    #endif
    new tmp[32], mode
    
    if (id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED
    }
    if(status==0){
        (id==0) ? war_servertext("clt_abort") : war_clienttext(id, "clt_abort")
    }
    else if(read_argc() < 1) (id==0) ? war_servertext("clt_info5") : war_clienttext(id, "clt_info5")
    else{
        read_argv(1, tmp, 31)
        mode = str_to_num(tmp)
        
        if((mode!=1) && (mode!=2)){
            (id==0) ? war_servertext("clt_info5") : war_clienttext(id, "clt_info5")
            return PLUGIN_HANDLED
        }
        war_dorestart(mode)
    }
    
    return PLUGIN_HANDLED
}

public war_end(abort){
    #if defined DEBUG
    log_amx("* war_end(%d)", abort)
    #endif
    new cfg[64]
    
    status = 0
    captain_id[0] = 0
    captain_id[1] = 0

    war_delvaults()
    remove_task(TID_COUNTDOWN)
    remove_task(TID_ONLYKNIFE)
    remove_task(TID_RESTARTS)
    remove_task(TID_MSG)
    #if defined HLTV_SUPPORT
    remove_task(TID_HLTVREC)
    #endif
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    get_cvar_string("xw_public_cfg",cfg,63)
    server_cmd("exec ^"%s^"",cfg)
    format(war_password, 31, "")
    
    #if defined HLTV_SUPPORT
    if((abort) && (hltv_status == 2)) war_hltvstop()
    #endif
    if(abort) war_demo_off()

    server_cmd("sv_password ^"%s^"", serv_password)
    server_cmd("exec %s/x-war.cfg",cfgdir)

    return PLUGIN_CONTINUE
}

public war_endhack(id){
    #if defined DEBUG
    log_amx("* war_endhack(%d)", id - AID_EHACK)
    #endif   
    new x
    
    id -= AID_EHACK
    
    if(id == 1) (t_score[0][1]+t_score[0][2] >= maxrounds+1) ? war_hudtext(MID_ALL,"hud_stop4TER",60,2,10) : war_hudtext(MID_ALL,"hud_stop4CT",60,2,10)
    if(id == 2) war_hudtext(MID_ALL,"hud_stop5",60,2,10)
    set_task(float(x), "war_end")
    #if defined HLTV_SUPPORT
    if(hltv_status == 2) set_task(float(hltv_rec_delay + HLTV_ADDDELAY), "war_hltvstop")
    #endif
    
    return PLUGIN_CONTINUE
}

public war_abort(id){
    #if defined DEBUG
    log_amx("* war_abort(%d)",id)
    #endif
    if (id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED
    }
    if(status == 0){
        (id==0) ? war_servertext("clt_abort") : war_clienttext(id, "clt_abort")
        return PLUGIN_HANDLED
    }
    get_user_name(id,adminname,31)
    war_hudtext(MID_ALL,"hud_stop6",20,2,10)
    war_hudtext(MID_ALL,"hud_stop6",20,2,4)
    war_clienttext(id, "clt_start4")
    war_end(1)
    
    return PLUGIN_HANDLED
}

//===========================================================================================
//************************************   EVENTS   *******************************************
//===========================================================================================
public client_disconnect(id){
    if(!status) return PLUGIN_CONTINUE
    
    #if defined DEBUG
    log_amx("* client_disconnect(%d)",id)
    #endif
    #if defined HLTV_SUPPORT
    if(is_user_hltv(id)){
        hltv_id = 0
        hltv_address = -1
    }
    #endif
    if((status == 0) || (war_getuserteam(id) == 2)) return PLUGIN_CONTINUE
    if((status == 1) || (status==7)){
        if(readyplayers[id] == 1) war_removeready(id)
        return PLUGIN_CONTINUE
    }

    if(id == captain_id[0]) captain_id[0]=0
    if(id == captain_id[1]) captain_id[1]=0

    return PLUGIN_CONTINUE
}

public client_putinserver(id){
    if((status == 1) || (status==7)){
        #if defined DEBUG
        if(is_user_bot(id)) set_task(1.0, "war_readycheck", AID_RCHECK + id)
        #endif
        if(!is_user_bot(id)) set_task(3.0, "war_warmup_hud", AID_WHUD + id)
    }
    #if defined HLTV_SUPPORT
    if(is_user_hltv(id)){
        set_task(1.0, "war_hltvinit", AID_HINIT + id)
        return PLUGIN_CONTINUE
    }
    #endif

    #if defined DEBUG
    if(status) log_amx("* client_putinserver(%d)",id)
    #endif
    
    return PLUGIN_CONTINUE
}

public war_say(id){
    if(!status || is_user_hltv(id)) return PLUGIN_CONTINUE
    new message[192]

    read_args(message,191)
    remove_quotes(message)
    #if defined DEBUG
    log_amx("* war_say(%d, %s)", id, message)
    #endif
    if((status==1) || (status==7)){
        if(equali(message, "ready")) return war_readycheck(AID_RCHECK + id)
        else if(equali(message, "captain")) return war_captain(id)
        else if(equali(message, "notready")) return war_notreadycheck(id)
        
        return PLUGIN_CONTINUE
    }
    
    if(!get_cvar_num("xw_gag") || (id && (get_user_flags(id) & CMDACCESS))) return PLUGIN_CONTINUE
    
    new team = war_getuserteam(id)
    if(team != 2)
        if(id == captain_id[team]) return PLUGIN_CONTINUE
    
    war_clienttext(id, "clt_gag")
    return PLUGIN_HANDLED
}

public war_sayteam(id){
    if(!status || (status==1) || (status==7)) return PLUGIN_CONTINUE
    new message[192]

    read_args(message,191)
    remove_quotes(message)
    #if defined DEBUG
    log_amx("* war_sayteam(%d, %s)", id, message)
    #endif
    if(equali(message, "score")) return war_getscore(id)

    return PLUGIN_CONTINUE
}

public war_captain(id){
    if(!status) return PLUGIN_CONTINUE
    #if defined DEBUG
    log_amx("* war_captain(%d)", id)
    #endif
    new plteam = war_getuserteam(id)

    if(plteam == 2) return PLUGIN_CONTINUE
    captain_id[plteam] = id
    war_clienttext(id, "clt_captain")
    war_hudtext(id, "hud_captain", 10, 0, 1)
    war_warmup_hud(MID_ALL)
    
    return PLUGIN_HANDLED
}

public war_readycheck(id){
    if(status == 0) return PLUGIN_CONTINUE
    if(((status != 1) && (status!=7)) || (task_exists(TID_PRESTART))) return PLUGIN_HANDLED

    new playername[64], plteam

    id -= AID_RCHECK

    plteam = war_getuserteam(id)
    #if defined DEBUG
    log_amx("* war_readycheck(taskid=%d, id=%d, plteam=%d)", id, id - AID_RCHECK, plteam)
    #endif
    
    if(plteam == 2) return PLUGIN_CONTINUE
    //aaa
    if(readyplayers[id] == 1){
        war_clienttext(id, "clt_warmup2b")
        return PLUGIN_HANDLED
    }
    else {
        menu_cancel(id)
        readyplayers[id] = 1
        war_clienttext(id, "clt_warmup2a")
        get_user_name(id,playername,63)
        
        war_removeclantag(playername, plteam)
        
        p_ready[plteam]++
        if(strlen(whosready[plteam])==0) format(whosready[plteam],255,"%s", playername)
        else format(whosready[plteam],255,"%s, %s", whosready[plteam], playername)
        
        if(p_ready[0]+p_ready[1]>=minready*2) war_prestart()
        else war_warmup_hud(MID_ALL)
    }
    
    return PLUGIN_HANDLED
}

public war_notreadycheck(id){
    #if defined DEBUG
    log_amx("* war_notreadycheck(%d)", id)
    #endif
    new plteam = war_getuserteam(id)

    if((status == 0) || (plteam == 2)) return PLUGIN_CONTINUE
    if((status != 1) && (status!=7)) return PLUGIN_HANDLED
    if(readyplayers[id] == 0){
        war_clienttext(id, "clt_warmup3b")
        return PLUGIN_HANDLED
    }
    else {
        war_removeready(id)
        war_clienttext(id, "clt_warmup3a")
    }
    
    return PLUGIN_HANDLED
}

public war_getscore(id){
    #if defined DEBUG
    log_amx("* war_getscore(%d)", id)
    #endif
    if(status == 0) return PLUGIN_CONTINUE
    war_clienttext(id, "clt_info")
    
    return PLUGIN_HANDLED
}

public war_roundend(){
    if(!status) return PLUGIN_HANDLED
    
    #if defined DEBUG
    server_print("* war_roundend(status=%d)", status)
    #endif
    //if(status == 0) return PLUGIN_HANDLED
    
    new tmp = 0, half, str[16], str2[16], team
    
    read_data(2, str, 15)
    team = equal(str, "%!MRAD_ctwin") ? 0 : 1
    
    half = (status < 7) ? 1 : 2
    #if defined DEBUG
    server_print("* half=%d, team=%d", half, team)
    #endif
    if (status == 3){
        war_show_sts(captain_id[team])
        set_task(float(STS_TIMEOUT), "war_prestart", TID_STSTIMEOUT)
        status = 4;set_vaultdata("cw_status", "4")
        #if defined DEBUG
        server_print("**********************************************")
        server_print("              status=%d", status)
        server_print("**********************************************")
        #endif
    }
    else if ((status == 6) || (status == 9)){
        if (((team == 1) && (status == 6)) || ((team == 0) && (status == 9))) tmp = 1
        t_score[tmp][0]++
        t_score[tmp][half]++

        format(str, 15, "cw_score%d0", tmp)
        format(str2, 15, "%d", t_score[tmp][0])
        set_vaultdata(str, str2)

        format(str, 15, "cw_score%d%d", tmp, half)
        format(str2, 15, "%d", t_score[tmp][half])
        set_vaultdata(str, str2)

        if ((t_score[0][half]+t_score[1][half] == maxrounds) && (status == 6)){
            status = 7;     set_vaultdata("cw_status", "7")
            #if defined DEBUG
            server_print("**********************************************")
            server_print("              status=%d", status)
            server_print("**********************************************")
            #endif
            if((strlen(t_name[0])>0) && (strlen(t_name[1])>0)){
                set_vaultdata("cw_team1",t_name[0])
                set_vaultdata("cw_team2",t_name[1])
            }
            num_to_str(status, str, 15)
            set_vaultdata("cw_status",str)
            war_ss()
            set_task(1.9, "war_swapnames")
            if(get_cvar_num("xw_swapteams") == 1) set_task(2.0,"war_swapteams")
            (get_cvar_num("xw_warmup_timelimit") != -1) ? set_task(2.0,"war_warmup") : set_task(2.0,"war_prestart")
        }
        else if((t_score[0][1]+t_score[0][2] == maxrounds) && (t_score[1][1]+t_score[1][2] == maxrounds)){
            if(get_cvar_num("xw_tie") == 1){            // tied
                war_ss()
                set_task(5.0,"war_endhack", AID_EHACK + 2)
            }
            else{                            // go to overtime
                maxrounds = get_cvar_num("xw_ot_rounds")
                set_cvar_num("xw_maxrounds", maxrounds)
                status = 1;     set_vaultdata("cw_status", "1")
                #if defined DEBUG
                server_print("**********************************************")
                server_print("              status=%d", status)
                server_print("**********************************************")
                #endif
                period_number++;   
                num_to_str(period_number, str, 63)
                set_vaultdata("cw_period_number",str)
                
                t_score[0][1] = 0;    set_vaultdata("cw_score01", "0")
                t_score[0][2] = 0;    set_vaultdata("cw_score02", "0")
                t_score[1][1] = 0;    set_vaultdata("cw_score11", "0")
                t_score[1][2] = 0;    set_vaultdata("cw_score12", "0")
                war_swapnames(0)
                
                war_ss()
                if(get_cvar_num("xw_swapteams") == 1){
                    war_hudtext(MID_ALL,"hud_stop2a",5,1,6)
                    set_task(2.0,"war_swapteams")
                }
                else war_hudtext(MID_ALL,"hud_stop2b",20,2,6)
                (get_cvar_num("xw_warmup_timelimit") != -1) ? set_task(2.0,"war_warmup") : set_task(2.0,"war_prestart")
            }
        }
        else if (((gametype == 0) && ((t_score[0][1]+t_score[0][2] == maxrounds+1) || (t_score[1][1]+t_score[1][2] == maxrounds+1)))
            || ((gametype == 1) && (t_score[0][1]+t_score[0][2]+t_score[1][1]+t_score[1][2] == maxrounds*2))){
            status = 0
            #if defined DEBUG
            server_print("**********************************************")
            server_print("              status=%d", status)
            server_print("**********************************************")
            #endif
            war_ss()
            set_task(5.3,"war_endhack", AID_EHACK + 1)
        }
        else set_task(6.0,"war_scoreinfo")
    }
    else if((status == 1) || (status == 7))    set_task(5.3, "war_warmup_hud", MID_SPEC)
    #if defined DEBUG
    server_print("* score: [%d,%d,%d], [%d,%d,%d]", t_score[0][0], t_score[0][1], t_score[0][2], t_score[1][0], t_score[1][1], t_score[1][2])
    #endif
    
    return PLUGIN_CONTINUE
}

public war_hudreset(id){
    if(!status || is_user_bot(id)) return PLUGIN_CONTINUE

    #if defined DEBUG
    log_amx("* war_hudreset(%d)",id)
    #endif
    
    if((status == 1) || (status==7)){
        new team = war_getuserteam(id)
        
        if(!captain_id[team]){
            new name[64]
        
            get_user_name(id, name, 63)
            if(containi(name, CLANLEADERTAG)!=-1){
                captain_id[team] = id
                //update whosready string HUD
            }
        }

        set_task(0.3, "war_warmup_hud", AID_WHUD + id)
        if(get_cvar_num("xw_readymenu")) set_task(10.0, "war_show_rdy", AID_SRDY + id)
        war_clienttext(id, "clt_warmupinfo")
    }
    
    return PLUGIN_CONTINUE
}

public war_chooseteam(id){
    if(!status) return PLUGIN_CONTINUE
    
    #if defined DEBUG
    log_amx("* war_chooseteam(%d)",id)
    #endif       
    if(!status || !get_cvar_num("xw_block_chooseteam")) return PLUGIN_CONTINUE
    if((status==1) || (status==7)){
        if(readyplayers[id]) war_removeready(id)
    }
    else{
        war_clienttext(id, "clt_blocked")
        return PLUGIN_HANDLED   
    }
    
    return PLUGIN_CONTINUE
}

public bomb_explode(planter, defuser){
    if(!status) return PLUGIN_CONTINUE
    
    #if defined DEBUG
    log_amx("* bomb_explode(%d, %d)", planter, defuser)
    #endif
    if(get_cvar_num("xw_onlykillfrags")) set_user_frags(planter, get_user_frags(planter)-3)
    
    return PLUGIN_CONTINUE
}

public bomb_defused(defuser){
    if(!status) return PLUGIN_CONTINUE
    
    #if defined DEBUG
    log_amx("* bomb_defused(%d)",defuser)
    #endif
    if(get_cvar_num("xw_onlykillfrags")) set_user_frags(defuser, get_user_frags(defuser)-3)
    
    return PLUGIN_CONTINUE
}

public war_clchangename(){
    if(!status) return PLUGIN_CONTINUE
    
    #if defined DEBUG
    log_amx("* war_clchangename()")
    #endif
    if((status != 1) && (status != 7)) return PLUGIN_CONTINUE
    new text[64], name[64], newname[64], userid, authid[16], plteam[16], tmp
    
    read_logargv(0,text,63)
    #if defined DEBUG
    log_amx("%s", text)
    #endif

    parse_loguser(text, name, 63, userid, authid, 15, plteam, 1)
    #if defined DEBUG
    log_amx("oldname: %s, plteam: %s", name, plteam)
    #endif
    
    switch(plteam[0]){
        case 'C': tmp = 0
        case 'T': tmp = 1
        default : return PLUGIN_CONTINUE
    }
    read_logargv(2,newname,63)
    #if defined DEBUG
    log_amx("%s", newname)
    #endif
    
    war_removeclantag(name, tmp)
    war_removeclantag(newname, tmp)
    replace(whosready[tmp], 255, name, newname)
    war_warmup_hud(MID_ALL)
    
    return PLUGIN_CONTINUE
}
//===========================================================================================
//************************************   HLTV   *********************************************
//===========================================================================================
#if defined HLTV_SUPPORT
public war_hltvrecord(){
    #if defined DEBUG
    log_amx("* war_hltvrecord()")
    #endif
    if(hltv_address == -1) return PLUGIN_CONTINUE
    
    new demoname[128], dir[128]
    if((strlen(t_name[0])>0) && (strlen(t_name[1])>0)){
        format(demoname,127,"%s-vs-%s_hltv",t_name[0],t_name[1])
        // Remove bad strings before recording
        while(replace(demoname,256,"/","-")) {}
        while(replace(demoname,256,"\","-")) {}
        while(replace(demoname,256,":","-")) {}
        while(replace(demoname,256,"*","-")) {}
        while(replace(demoname,256,"?","-")) {}
        while(replace(demoname,256,">","-")) {}
        while(replace(demoname,256,"<","-")) {}
        while(replace(demoname,256,"|","-")) {}
    }
    else format(demoname,127,"hltv")
    
    get_cvar_string("xw_hltv_demosdir", dir, 127)
    format(demoname,127,"record ^"%s%s^"", dir,demoname)
    war_hltvrcon("stoprecording")
    war_hltvread(AID_HREAD + 0)
    
    set_task(1.0, "war_hltvrcon", 0, demoname, strlen(demoname))
    set_task(1.5, "war_hltvread", AID_HREAD + 2)
    
    return PLUGIN_CONTINUE
}   

public war_hltvstop(){
    #if defined DEBUG
    log_amx("* war_hltvstop()")
    #endif
    if(hltv_address == -1) return PLUGIN_CONTINUE
    war_hltvrcon("stoprecording")
    set_task(0.5, "war_hltvread", AID_HREAD + 3)
    
    return PLUGIN_CONTINUE
}

public war_hltvrcon(cmd[]){
    #if defined DEBUG
    log_amx("* war_hltvrcon(%s)",cmd)
    #endif
    new rcv[256],snd[256],rconid[13],error
    
    // Connect to HLTV Proxy
    hltv_address = socket_open(hltv_ip, hltv_port, SOCKET_UDP, error)
    if(error != 0){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_hltverror", error)
        #endif
        return PLUGIN_CONTINUE
    }
    
    //send challenge rcon and receive response
    setc(snd,4,0xff)
    format(snd[4],255,"challenge rcon")
    setc(snd[18],1,'^n')
    socket_send(hltv_address,snd,255)
    socket_recv(hltv_address,rcv,255)
    
    // get hltv rcon challenge number from response
    format(rconid,12,"%s",rcv[19])
    replace(rconid,255,"^n","")
    
    // send rcon command and close socket
    setc(snd,255,0x00)
    setc(snd,4,0xff)
    format(snd[4],255,"rcon %s ^"%s^" %s^n",rconid,hltv_pass,cmd)
    socket_send(hltv_address,snd,255)
    
    return PLUGIN_CONTINUE
}

public war_hltvinit(id){
    #if defined DEBUG
    log_amx("* war_hltvinit(%d)", id - AID_HINIT)
    #endif
    new textblock[textblock_size]
    
    get_cvar_string("xw_hltv_passw", hltv_pass, 31)
    if((strlen(hltv_pass) > 0) && (hltv_address == -1)){
        new tmp[32], tmp2[16]
        
        hltv_id = id - AID_HINIT
        get_user_ip(hltv_id,tmp,31)
        new pos = copyc(hltv_ip,15,tmp,':') + 1
        format(tmp2,15,"%s",tmp[pos])
        hltv_port = str_to_num(tmp2)
        #if defined HLTV_PUBLIC_PORT
        if(hltv_port == HLTV_PUBLIC_PORT){
            return PLUGIN_CONTINUE
        }
        #endif
        
        #if defined DEBUG
        log_amx("hltv ip is %s, port is %d, id is %d", hltv_ip, hltv_port, hltv_id)
        #endif
        if(war_parsestrini2("clt_info8")>0){
            format(textblock, textblock_size-1, "say %L", LANG_SERVER, "clt_info8")
            war_hltvrcon(textblock)
            war_hltvread(AID_HREAD + 0)
        }
        set_task(1.0, "war_hltvrcon", 0, "delay", 5)
        set_task(1.5, "war_hltvread", AID_HREAD + 1)
        
        set_task(2.0, "war_hltvrcon", 0, "stoprecording", 13)
        set_task(2.0, "war_hltvread", AID_HREAD + 0)
    }
    
    return PLUGIN_CONTINUE
}

public war_hltvread(mode){
    #if defined DEBUG
    log_amx("* war_hltvread(%d)", mode - AID_HREAD)
    #endif
    mode -= AID_HREAD
    if (socket_change(hltv_address , 100)){
        new buf[512], dir[128]
        socket_recv(hltv_address , buf, 511)
        #if defined DEBUG
        log_amx("%s",buf[5])
        #endif
        if(mode==1){
            hltv_rec_delay = str_to_num(buf[56])
            #if defined DEBUG
            log_amx("hltv_rec_delay = %d",hltv_rec_delay)
            #endif
            hltv_status = 1
        }
        if(mode>1){
            format(buf,511,"say %s",buf[5])
            socket_close(hltv_address)
            if(mode==3){
                get_cvar_string("xw_hltv_demosdir", dir, 127)
                replace(buf, 511, dir , "")
            }
            war_hltvrcon(buf)
        }
        if(mode==2) hltv_status = 2
        if(mode==3) hltv_status = 1
    }
    else if(mode>0){
        war_servertext("clt_info9")
        war_clienttext(MID_ALL, "clt_info9")
        hltv_status = 0
    }
    socket_close(hltv_address)
    
    return PLUGIN_CONTINUE
}
#endif
//===========================================================================================
//************************************   MENU   *********************************************
//===========================================================================================
public war_ma_mm(id) {
    /* This event is called when an item was selected */
}

public war_action_mm(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_mm(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    if(status == 0){
        if(item > 0) item += 3
    }
    else if((status != 1) && (status != 7) && item != MENU_EXIT) item++

    switch(item){
        case 0:    if(status == 0){
                war_loadini()
                war_findtags()
                war_show_wm(id, 0, menu)
            }
            else{
                war_forcestart(id)
                menu_destroy(menu)
            }
        case 1: {
            war_abort(id)
            menu_destroy(menu)
        }
        case 2: war_show_rm(id, menu)
        case 3: {
            war_swapnames(id)
            menu_destroy(menu)
        }
        case 4: {
            war_swapteams()
            menu_destroy(menu)
        }
        case 5: war_show_sm(id, 0, menu)
        case MENU_EXIT:
            menu_destroy(menu)
        default:
            menu_display(id, menu, 0)
    }
    
    return PLUGIN_HANDLED
}

public war_show_mm(id){
    #if defined DEBUG
    log_amx("* war_show_mm(%d)",id)
    #endif
    new str[64], menu
    if(id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED
    }

    format(str, 63, "%L", id, "menu_mm_header")
    menu = menu_create(str, "war_action_mm")
    
    if(status == 0){
        format(str, 63, "%L", id, "menu_mm_item1")
        menu_additem(menu, str, "war_ma_mm", CMDACCESS)
    }
    else{
        if((status==1) || (status==7)){
            format(str, 63, "%L", id, "menu_mm_item2")
            menu_additem(menu, str, "war_ma_mm", CMDACCESS)
        }
        format(str, 63, "%L", id, "menu_mm_item3")
        menu_additem(menu, str, "war_ma_mm", CMDACCESS)
        format(str, 63, "%L", id, "menu_mm_item4")
        menu_additem(menu, str, "war_ma_mm", CMDACCESS)
        format(str, 63, "%L", id, "menu_mm_item5")
        menu_additem(menu, str, "war_ma_mm", CMDACCESS)
    }
    format(str, 63, "%L", id, "menu_mm_item6")
    menu_additem(menu, str, "war_ma_mm", CMDACCESS)
    format(str, 63, "%L", id, "menu_mm_item7")
    menu_additem(menu, str, "war_ma_mm", SETTINSMENUACCESS)
    
    format(str, 63, "%L", id, "menu_exit")
    menu_setprop(menu, MPROP_EXITNAME, str)
    
    menu_display(id, menu, 0)
    
    return PLUGIN_HANDLED
}

public war_action_rm(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_rm(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    (item == MENU_EXIT) ? set_task(0.1, "war_show_mm", id) : war_dorestart(item+1)

    menu_destroy(menu)
    
    return PLUGIN_HANDLED
}

public war_show_rm(id, oldmenu){
    #if defined DEBUG
    log_amx("* war_show_rm(%d)",id)
    #endif
    new str[64], menu
    
    menu_destroy(oldmenu)
    
    format(str, 63, "%L", id, "menu_rm_header")
    menu = menu_create(str, "war_action_rm")
    format(str, 63, "%L", id, "menu_rm_item1")
    menu_additem(menu, str)
    format(str, 63, "%L", id, "menu_rm_item2")
    menu_additem(menu, str)
    
    format(str, 63, "%L", id, "menu_exit")
    menu_setprop(menu, MPROP_EXITNAME, str)
//    menu_setprop(menu , MPROP_EXIT, MEXIT_ALL)
    menu_display(id, menu, 0)
    
    return PLUGIN_HANDLED
}

public war_action_sm(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_sm(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    new filename[128], x
    
    format(filename,127,"%s/x-war.cfg",cfgdir)
    switch(item){
        case 0: {
            x = get_cvar_num("xw_tie")+1
            if(x > 1) x = 0
            set_cvar_num("xw_tie",x)
            war_show_sm(id, 0, menu)
        }
        case 1: {
            x = get_cvar_num("xw_ot_rounds")+1
            if(x > 15) x=2
            set_cvar_num("xw_ot_rounds",x)
            war_show_sm(id, 0, menu)
        }
        case 2: {
            x = get_cvar_num("xw_warmup_timelimit")
            if(x%5==0) x+=5
            else while(x %5 !=0) x++
            if(x > 30) x = 0
            set_cvar_num("xw_warmup_timelimit",x)
            war_show_sm(id, 0, menu)
        }
        case 3: {
            x = get_cvar_num("xw_knife_round")+1
            if(x > 1) x = 0
            set_cvar_num("xw_knife_round",x)
            war_show_sm(id, 0, menu)
        }
        case 4: {
            x = get_cvar_num("xw_demos")+1
            if(x > 2) x = 0
            set_cvar_num("xw_demos",x)
            war_show_sm(id, 0, menu)
        }
        case 5: {
            x = get_cvar_num("xw_screenshots")+1
            if(x > 1) x = 0
            set_cvar_num("xw_screenshots",x)
            war_show_sm(id, 0, menu)
        }
        case 6:    {
            war_logsettings(filename)
            war_show_sm(id, 0, menu)
        }
        case 7: {
            x = get_cvar_num("xw_swapteams")+1
            if(x > 1) x=0
            set_cvar_num("xw_swapteams",x)
            war_show_sm(id, 1, menu)
        }
        case 8: {
            x = get_cvar_num("xw_block_chooseteam")+1
            if(x > 1) x=0
            set_cvar_num("xw_block_chooseteam",x)
            war_show_sm(id, 1, menu)
        }
        case 9: {
            x = get_cvar_num("xw_onlykillfrags")+1
            if(x > 1) x=0
            set_cvar_num("xw_onlykillfrags",x)
            war_show_sm(id, 1, menu)
        }
        case 10:{
            x = get_cvar_num("xw_readymenu")+1
            if(x > 1) x=0
            set_cvar_num("xw_readymenu",x)
            war_show_sm(id, 1, menu)
        }
        case 11:{
            x = get_cvar_num("xw_gag")+1
            if(x > 1) x=0
            set_cvar_num("xw_gag",x)
            war_show_sm(id, 1, menu)
        }
//        case 12:
//            menu_display(id, menu, 1)
        case 12:{
            war_logsettings(filename)
            war_show_sm(id, 1, menu)
        }
        case MENU_EXIT:{
            menu_destroy(menu)
            war_show_mm(id)
        }
    }
    
    return PLUGIN_HANDLED
}

public war_show_sm(id, page, oldmenu){
    #if defined DEBUG
    log_amx("* war_show_sm(%d)",id)
    #endif
    new str[128], menu, q_format[3][20]
    
    menu_destroy(oldmenu)
    
    format(q_format[0], 19, "%L", id, "menu_no")
    format(q_format[1], 19, "%L", id, "menu_yes")
    format(q_format[2], 19, "%L", id, "menu_ask")
    
    format(str, 127, "%L", id, "menu_sm_header")
    menu = menu_create(str, "war_action_sm")
    
    format(str, 127,"%L \y%s", id, "menu_sm_item01", q_format[get_cvar_num("xw_tie")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%d", id, "menu_sm_item02", get_cvar_num("xw_ot_rounds"))
    menu_additem(menu, str)
    format(str, 127,"%L \y%d", id, "menu_sm_item03", get_cvar_num("xw_warmup_timelimit"))
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item04", q_format[get_cvar_num("xw_knife_round")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item05", q_format[get_cvar_num("xw_demos")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item06", q_format[get_cvar_num("xw_screenshots")])
    menu_additem(menu, str)
    menu_addblank(menu, 0)
    format(str, 127,"%L", id, "menu_sm_item07")
    menu_additem(menu, str)

    format(str, 127,"%L \y%s", id, "menu_sm_item08", q_format[get_cvar_num("xw_swapteams")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item09", q_format[get_cvar_num("xw_block_chooseteam")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item10", q_format[get_cvar_num("xw_onlykillfrags")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item11", q_format[get_cvar_num("xw_readymenu")])
    menu_additem(menu, str)
    format(str, 127,"%L \y%s", id, "menu_sm_item12", q_format[get_cvar_num("xw_gag")])
    menu_additem(menu, str)
    menu_addblank(menu)
    menu_addblank(menu, 0)
    format(str, 127,"%L", id, "menu_sm_item14")
    menu_additem(menu, str)

    format(str, 127,"%L", id, "menu_back")
    menu_setprop(menu, MPROP_BACKNAME, str)
    format(str, 127,"%L", id, "menu_exit")
    menu_setprop(menu, MPROP_EXITNAME, str)
    format(str, 127,"%L", id, "menu_next")
    menu_setprop(menu, MPROP_NEXTNAME, str)
    
    menu_setprop(menu, MPROP_PERPAGE, 7)
//    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, page)
    
    return PLUGIN_HANDLED
}

public war_action_wm(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_wm(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    new tmp
    
    switch(item){
        case 0: {
            clan1_toshow++
            if(clan1_toshow == 1) clan1_toshow++
            if(clan1_toshow == clan2_toshow) clan1_toshow++
            if(clan1_toshow >= num_clans) clan1_toshow = 0
            war_show_wm(id, 0, menu)
        }
        case 1: {
            clan2_toshow++
            if(clan2_toshow == clan1_toshow) clan2_toshow++
            if(clan2_toshow >= num_clans) clan2_toshow = 1
            war_show_wm(id, 0, menu)
        }
        case 2: {
            tmp = get_cvar_num("xw_minready")
            if(tmp > 4) set_cvar_num("xw_minready", 1)
            else  set_cvar_num("xw_minready", tmp + 1)
            war_show_wm(id, 0, menu)
        }
        case 3: {
            tmp = get_cvar_num("xw_gametype")
            if(tmp > 0) set_cvar_num("xw_gametype", 0)
            else set_cvar_num("xw_gametype", 1)
            war_show_wm(id, 0, menu)
        }
        case 4: {
            tmp = get_cvar_num("xw_maxrounds")
            if(tmp > 19) set_cvar_num("xw_maxrounds", 2)
            else set_cvar_num("xw_maxrounds", tmp + 1)
            war_show_wm(id, 0, menu)
        }
        case 5: {
            map_toshow++
            if(map_toshow>=num_maps) map_toshow=0
            war_show_wm(id, 0, menu)
        }
        case 6, 10: {
            #if defined HLTV_SUPPORT
            if(hltv_status == 2){
                (id==0) ? war_servertext("clt_info6") : war_clienttext(id, "clt_info6")
                return PLUGIN_HANDLED
            }
            #endif
            status = 1;     set_vaultdata("cw_status", "1")
            #if defined DEBUG
            log_amx("**********************************************")
            log_amx("              status=%d", status)
            log_amx("**********************************************")
            #endif
            war_init()
            if((clan1_toshow>1) && (clan2_toshow>1)){
                format(t_name[0], 31, "%s", clans[clan1_toshow])
                format(t_name[1], 31, "%s", clans[clan2_toshow])
            }
            else{
                format(t_name[0], 31, "")
                format(t_name[1], 31, "")
            }
            war_setvaults()
            
            new curmap[32]
            get_mapname(curmap,31)
            if(strcmp(curmap, maps[map_toshow], true)){
                set_vaultdata("cw_map", maps[map_toshow])
                server_cmd("changelevel %s",maps[map_toshow])
            }
            
            war_warmup()
            menu_destroy(menu)
        }
        case 7: {
            cfg_toshow++
            if(cfg_toshow>=num_cfgs) cfg_toshow=0
            set_cvar_string("xw_configs", cfgs[cfg_toshow])
            war_show_wm(id, 1, menu)
        }
        case 8: {
            pwd_toshow++
            if(pwd_toshow>=num_pwds) pwd_toshow=0
            format(war_password, 31, "%s", pwds[pwd_toshow])
            war_show_wm(id, 1, menu)
        }
        case 9:
            menu_display(id, menu, 1)
        case MENU_EXIT:{
            menu_destroy(menu)
            war_show_mm(id)
        }
    }
    
    return PLUGIN_HANDLED
}

public war_show_wm(id, page, oldmenu){
    #if defined DEBUG
    log_amx("* war_show_wm(%d)",id)
    #endif
    new str[128], menu
    
    menu_destroy(oldmenu)
    
    format(str, 127, "%L", id, "menu_wm_header")
    menu = menu_create(str, "war_action_wm")
    format(clans[0], 31, "%L", id, "CTname")
    format(clans[1], 31, "%L", id, "Tname")
    
    format(str,127, "%L \y%s", id, "menu_wm_item01", clans[clan1_toshow])
    menu_additem(menu, str)
    format(str,127, "%L \y%s", id, "menu_wm_item02", clans[clan2_toshow])
    menu_additem(menu, str)
    format(str,127,"%L \y%d", id, "menu_wm_item03", get_cvar_num("xw_minready"))
    menu_additem(menu, str)
    format(str,127,"%L \y%s", id, "menu_wm_item04", gt[get_cvar_num("xw_gametype")])
    menu_additem(menu, str)
    format(str,127,"%L \y%d", id, "menu_wm_item05", get_cvar_num("xw_maxrounds"))
    menu_additem(menu, str)
    format(str,127,"%L \y%s", id, "menu_wm_item06", maps[map_toshow])
    menu_additem(menu, str)
    menu_addblank(menu, 0)
    format(str,127,"%L", id, "menu_wm_item07")
    menu_additem(menu, str)

    format(str,127,"%L \y%s", id, "menu_wm_item08", cfgs[cfg_toshow])
    menu_additem(menu, str)
    format(str,127,"%L \y%s", id, "menu_wm_item09", pwds[pwd_toshow])
    menu_additem(menu, str)
    format(str,127,"%s", id, "---")
    menu_additem(menu, str)
    menu_addblank(menu)
    menu_addblank(menu)
    menu_addblank(menu)
    menu_addblank(menu, 0)
    format(str,127,"%L", id, "menu_wm_item14")
    menu_additem(menu, str)

    format(str, 127,"%L", id, "menu_back")
    menu_setprop(menu, MPROP_BACKNAME, str)
    format(str, 127,"%L", id, "menu_exit")
    menu_setprop(menu, MPROP_EXITNAME, str)
    format(str, 127,"%L", id, "menu_next")
    menu_setprop(menu, MPROP_NEXTNAME, str)
    
    menu_setprop(menu, MPROP_PERPAGE, 7)
//    menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
    
    menu_display(id, menu, page)
    
    return PLUGIN_HANDLED
}

public war_action_sts(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_sts(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    if(item == MENU_EXIT) return PLUGIN_HANDLED
    if(item == war_getuserteam(id)){
        set_task(0.9,"war_swapnames")
        set_task(1.0,"war_swapteams")
    }
    remove_task(TID_STSTIMEOUT)
    menu_sts = 0
    war_prestart()
    
    return PLUGIN_HANDLED
}

public war_show_sts(id){
    #if defined DEBUG
    log_amx("* war_show_sts(%d)",id)
    #endif
    new str[32]
    
    format(str, 31, "%L", id, "menu_sts_header")
    menu_sts = menu_create(str, "war_action_sts")
    format(str, 31, "%L", id, "menu_sts_item1")
    menu_additem(menu_sts, str)
    format(str, 31, "%L", id, "menu_sts_item2")
    menu_additem(menu_sts, str)
    menu_setprop(menu_sts , MPROP_EXIT, MEXIT_NEVER)
    menu_display(id, menu_sts, 0)
    
    return PLUGIN_HANDLED
}

public war_action_rdy(id, menu, item){
    #if defined DEBUG
    log_amx("* war_action_rdy(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    if(item==0) war_readycheck(AID_RCHECK + id)
    
    return PLUGIN_HANDLED
}

public war_show_rdy(id){
    #if defined DEBUG
    log_amx("* war_show_rdy(%d)", id - AID_SRDY)
    #endif
    new str[32], menu
    
    id -= AID_SRDY
    
    if(readyplayers[id] || ((status != 1) && (status!=7))) return PLUGIN_HANDLED
    
    format(str, 31, "%L", id, "menu_rdy_header")
    menu = menu_create(str, "war_action_rdy")
    format(str, 31, "%L", id, "menu_yes")
    menu_additem(menu, str)
    format(str, 31, "%L", id, "menu_no")
    menu_additem(menu, str)
    menu_setprop(menu , MPROP_EXIT, MEXIT_NEVER)
    menu_display(id, menu, 0)
    
    return PLUGIN_HANDLED
}

public war_demo_off(){
    #if defined DEBUG
    log_amx("* war_demo_off()")
    #endif
    if(get_cvar_num("xw_demos") == 0) return PLUGIN_CONTINUE
    
    for(new i=0;i<pl_recnum;i++) client_cmd(pl_rec[i],"stop")
    
    return PLUGIN_HANDLED
}

public war_demo_action(id, menu, item){
    #if defined DEBUG
    log_amx("* war_demo_action(id=%d, menu=%d, item=%d)", id, menu, item)
    #endif
    if(item == 0){
        new name[64], client_demoname[64], curmap[32], time_date[32]
        new plteam = war_getuserteam(id)
        
        if(plteam == 2){
            log_amx(" ERROR!!! PLEASE SEND THIS LOG TO [email protected]")
            return PLUGIN_HANDLED
        }
        
        get_mapname(curmap,32)
        get_time("%Y%m%d_%H-%M",time_date,31)
        if((strlen(t_name[0])>0) && (strlen(t_name[1])>0)) format(client_demoname,256,"%s-vs-%s_%s_%s",t_name[0],t_name[1],curmap,time_date)
        else format(client_demoname,256,"%s_%s",curmap,time_date)
        while(replace(client_demoname,63,"/","-")) {}
        while(replace(client_demoname,63,"\","-")) {}
        while(replace(client_demoname,63,":","-")) {}
        while(replace(client_demoname,63,"*","-")) {}
        while(replace(client_demoname,63,"?","-")) {}
        while(replace(client_demoname,63,">","-")) {}
        while(replace(client_demoname,63,"<","-")) {}
        while(replace(client_demoname,63,"|","-")) {}
        while(replace(client_demoname,63,".","-")) {}
        
        get_user_name(id,name,63)
        war_removeclantag(name, plteam)
        while(replace(name,63,"/","-")) {}
        while(replace(name,63,"\","-")) {}
        while(replace(name,63,":","-")) {}
        while(replace(name,63,"*","-")) {}
        while(replace(name,63,"?","-")) {}
        while(replace(name,63,">","-")) {}
        while(replace(name,63,"<","-")) {}
        while(replace(name,63,"|","-")) {}
        
        client_cmd(id,"stop;record ^"%s_POV(%s)^"",client_demoname,name)
        if(menu != -1) pl_rec[pl_recnum++] = id
    }
    
    return PLUGIN_HANDLED
}

public war_demo(){
    #if defined DEBUG
    log_amx("* war_demo()")
    #endif
    if(get_cvar_num("xw_demos") == 0) return PLUGIN_HANDLED
    new menu,players[32],num_players,i, str[128]
    
    if(pl_recnum > 0){
        for(i=0;i<pl_recnum;i++) war_demo_action(pl_rec[i], -1, 0)
        return PLUGIN_HANDLED
    }
    
    get_players(players,num_players,"ch")
    for(i=0;i<num_players;i++){
        if(war_getuserteam(players[i])!=2){
            if(get_cvar_num("xw_demos") == 2){
                format(str, 127, "%L", players[i], "menu_demo_header")
                menu = menu_create(str, "war_demo_action")
                format(str, 127, "%L", players[i], "menu_yes")
                menu_additem(menu, str)
                format(str, 127, "%L", players[i], "menu_no")
                menu_additem(menu, str)
                menu_setprop(menu , MPROP_EXIT, MEXIT_NEVER)
                menu_display(players[i], menu, 0)           
            }
            else if(get_cvar_num("xw_demos") == 1) war_demo_action(players[i], 0, 0)
        }
    }
    
    return PLUGIN_HANDLED
}

//===========================================================================================
//************************************   MISC   *********************************************
//===========================================================================================
public war_logsettings(file[]){
    #if defined DEBUG
    log_amx("* war_logsettings(%s)",file)
    #endif
    new str[64]
    
    delete_file(file)
    
    format(str,63,"xw_tie %d", get_cvar_num("xw_tie"))
    write_file (file, str)
    
    format(str,63,"xw_screenshots %d", get_cvar_num("xw_screenshots"))
    write_file (file, str)
    
    format(str,63,"xw_demos %d", get_cvar_num("xw_demos"))
    write_file (file, str)
    
    #if defined HLTV_SUPPORT
    get_cvar_string("xw_hltv_passw", str, 63)
    format(str,63,"xw_hltv_passw ^"%s^"", str)
    write_file (file, str)
    
    get_cvar_string("xw_hltv_demosdir", str, 63)
    format(str,63,"xw_hltv_demosdir ^"%s^"", str)
    write_file (file, str)
    #endif
    
    format(str,63,"xw_swapteams %d", get_cvar_num("xw_swapteams"))
    write_file (file, str)
    
    format(str,63,"xw_ot_rounds %d", get_cvar_num("xw_ot_rounds"))
    write_file (file, str)
    
    format(str,63,"xw_warmup_timelimit %d", get_cvar_num("xw_warmup_timelimit"))
    write_file (file, str)
    
    get_cvar_string("xw_restarts", str, 63)
    format(str,63,"xw_restarts ^"%s^"", str)
    write_file (file, str)
    
    format(str,63,"xw_knife_round %d", get_cvar_num("xw_knife_round"))
    write_file (file, str)
    
    format(str,63,"xw_block_chooseteam %d", get_cvar_num("xw_block_chooseteam"))
    write_file (file, str)
    
    format(str,63,"xw_onlykillfrags %d", get_cvar_num("xw_onlykillfrags"))
    write_file (file, str)
    
    format(str,63,"xw_readymenu %d", get_cvar_num("xw_readymenu"))
    write_file (file, str)

    format(str,63,"xw_gag %d", get_cvar_num("xw_gag"))
    write_file (file, str)

    write_file (file, "")
    
    format(str,63,"xw_minready %d", get_cvar_num("xw_minready"))
    write_file (file, str)
    
    format(str,63,"xw_gametype %d", get_cvar_num("xw_gametype"))
    write_file (file, str)
    
    format(str,63,"xw_maxrounds %d", get_cvar_num("xw_maxrounds"))
    write_file (file, str)
    
    get_cvar_string("xw_configs", str, 63)
    format(str,63,"xw_configs ^"%s^"", str)
    write_file (file, str)
    
    get_cvar_string("xw_public_cfg", str, 63)
    format(str,63,"xw_public_cfg ^"%s^"", str)
    write_file (file, str)
    
    return PLUGIN_CONTINUE
}

public war_loadini(){
    #if defined DEBUG
    log_amx("* war_loadini()")
    #endif
    new inifile[64], str[32], tmp[128], DirH, pos, len
    
    format(inifile,63,"%s/clans.ini", cfgdir)
    num_clans = 2
    if(file_exists(inifile)){
        pos = 0
        while(read_file(inifile,pos++,tmp,127,len))
            if((tmp[0] != ';') && (strlen(tmp) > 1) && (num_clans < maxtagsini))
                copy(clans[num_clans++],31,tmp)
    }

    format(inifile,63,"%s/passwords.ini", cfgdir)
    num_pwds = 1
    format(pwds[0], 31, "")
    if(file_exists(inifile)){
        pos = 0
        while(read_file(inifile,pos++,tmp,127,len))
            if((tmp[0] != ';') && (strlen(tmp) > 1) && (num_pwds < maxtagsini))
                copy(pwds[num_pwds++],31,tmp)
    }
    
    get_mapname(str,31)
    format(inifile,63,"%s/maps.ini", cfgdir)
    num_maps = 0
    map_toshow = -1
    if(file_exists(inifile)){
        pos = 0
        while(read_file(inifile,pos++,tmp,127,len))
            if((tmp[0] != ';') && (strlen(tmp) > 1) && (num_maps < maxtagsini)){
                copy(maps[num_maps],31,tmp)
                if(strcmp(str, maps[num_maps++], true) == 0) map_toshow = num_maps-1;
            }
    }
    if(map_toshow == -1){
        copy(maps[num_maps],31,str)
        map_toshow = num_maps++
        write_file(inifile, str)
    }
    
    copy(cfgs[num_cfgs],31,"default")
    num_cfgs = 1
    format(tmp,127,"%s/cfg",cfgdir)
    DirH = open_dir(tmp,str,31)
    while(next_file(DirH,str,31)) if((contain(str,".cfg") != -1) && !equali(str,"default.cfg") && (num_cfgs < maxtagsini)){
        replace(str, 31, ".cfg", "")
        copy(cfgs[num_cfgs],31,str)
        num_cfgs++
        if(num_cfgs==64) break
    }
    close_dir(DirH)
    
    return PLUGIN_CONTINUE
}

public war_findtags(){
    #if defined DEBUG
    log_amx("* war_findtags()")
    #endif
    new players[32],playername[64],num_players, i, j
    
    get_players(players,num_players,"e","CT")
    for(i=0;i<num_players;i++){
        get_user_name(players[i], playername, 63)
        #if defined DEBUG
        log_amx("%s",playername)
        #endif
        for(j=2;j<num_clans;j++){
            #if defined DEBUG
            log_amx("====>>> %s",clans[j])
            #endif
            if(containi(playername, clans[j])==0){
                #if defined DEBUG
                log_amx("found %s - %d",clans[j], j)
                #endif
                clan1_toshow = j
                j = num_clans
            }
        }
    }
    
    get_players(players,num_players,"e","TERRORIST")
    for(i=0;i<num_players;i++){
        get_user_name(players[i], playername, 63)
        #if defined DEBUG
        log_amx("%s",playername)
        #endif
        for(j=2;j<num_clans;j++) if(clan1_toshow!=j){
            #if defined DEBUG
            log_amx("====>>> %s",clans[j])
            #endif
            if(containi(playername, clans[j])==0){
                #if defined DEBUG
                log_amx("found %s - %d",clans[j], j)
                #endif
                clan2_toshow = j
                j = num_clans
            }
        }
    }
    
    return PLUGIN_CONTINUE
}

public war_setvaults(){
    #if defined DEBUG
    log_amx("* war_setvaults()")
    #endif
    new str[64], mapname[32]

//Константы (в течение матча)
    set_vaultdata("cw_initialized","1")
    get_mapname(mapname, 31)
    set_vaultdata("cw_map", mapname)
    if((strlen(t_name[0])>0) && (strlen(t_name[1])>0)){
        set_vaultdata("cw_team1",t_name[0])
        set_vaultdata("cw_team2",t_name[1])
    }
    num_to_str(get_cvar_num("xw_minready"), str, 63)
    set_vaultdata("cw_minready",str)
    num_to_str(get_cvar_num("xw_gametype"), str, 63)
    set_vaultdata("cw_gametype",str)
    get_cvar_string("xw_configs", str, 63)
    set_vaultdata("cw_configs",str)
    num_to_str(get_cvar_num("xw_tie"), str, 63)
    set_vaultdata("cw_tie",str)
    num_to_str(get_cvar_num("xw_screenshots"), str, 63)
    set_vaultdata("cw_screenshots",str)
    num_to_str(get_cvar_num("xw_demos"), str, 63)
    set_vaultdata("cw_demos",str)
    num_to_str(get_cvar_num("xw_knife_round"), str, 63)
    set_vaultdata("cw_knife_round",str)
    set_vaultdata("cw_password",war_password)

//Переменные
    num_to_str(get_cvar_num("xw_block_chooseteam"), str, 63)
    set_vaultdata("cw_block_chooseteam",str)
    num_to_str(get_cvar_num("xw_onlykillfrags"), str, 63)
    set_vaultdata("cw_onlykillfrags",str)
    num_to_str(get_cvar_num("xw_gag"), str, 63)
    set_vaultdata("cw_gag",str)
    num_to_str(get_cvar_num("xw_swapteams"), str, 63)
    set_vaultdata("cw_swapteams",str)
    num_to_str(get_cvar_num("xw_readymenu"), str, 63)
    set_vaultdata("cw_readymenu",str)
    num_to_str(get_cvar_num("xw_warmup_timelimit"), str, 63)
    set_vaultdata("cw_warmup_timelimit",str)
    num_to_str(get_cvar_num("xw_ot_rounds"), str, 63)
    set_vaultdata("cw_ot_rounds",str)
    num_to_str(period_number, str, 63)
    set_vaultdata("cw_period_number",str)
    num_to_str(maxrounds, str, 63)
    set_vaultdata("cw_maxrounds",str)
    
    return PLUGIN_CONTINUE
}

public war_readvaults(){
    #if defined DEBUG
    log_amx("* war_readvaults()")
    #endif
    new str[64], map[32], curmap[32], tmp
    
    get_vaultdata("cw_map", map, 31)
    get_mapname(curmap, 31)
    if(!equali(map, curmap)){
        server_cmd("changelevel %s", map)
        return PLUGIN_HANDLED
    }
    if(vaultdata_exists("cw_team1")) get_vaultdata("cw_team1", t_name[0], 31)
    if(vaultdata_exists("cw_team2")) get_vaultdata("cw_team2", t_name[1], 31)
    get_vaultdata("cw_score00", str, 63)
    t_score[0][0] = str_to_num(str)
    get_vaultdata("cw_score01", str, 63)
    t_score[0][1] = str_to_num(str)
    get_vaultdata("cw_score02", str, 63)
    t_score[0][2] = str_to_num(str)
    get_vaultdata("cw_score10", str, 63)
    t_score[1][0] = str_to_num(str)
    get_vaultdata("cw_score11", str, 63)
    t_score[1][1] = str_to_num(str)
    get_vaultdata("cw_score12", str, 63)
    t_score[1][2] = str_to_num(str)
    get_vaultdata("cw_tie", str, 63)
    set_cvar_num("xw_tie", str_to_num(str))
    get_vaultdata("cw_demos", str, 63)
    set_cvar_num("xw_demos", str_to_num(str))
    get_vaultdata("cw_swapteams", str, 63)
    set_cvar_num("xw_swapteams", str_to_num(str))
    get_vaultdata("cw_ot_rounds", str, 63)
    set_cvar_num("xw_ot_rounds", str_to_num(str))
    get_vaultdata("cw_warmup_timelimit", str, 63)
    set_cvar_num("xw_warmup_timelimit", str_to_num(str))
    get_vaultdata("cw_knife_round", str, 63)
    set_cvar_num("xw_knife_round", str_to_num(str))
    get_vaultdata("cw_block_chooseteam", str, 63)
    set_cvar_num("xw_block_chooseteam", str_to_num(str))
    get_vaultdata("cw_onlykillfrags", str, 63)
    set_cvar_num("xw_onlykillfrags", str_to_num(str))

    get_vaultdata("cw_minready", str, 63)
    set_cvar_num("xw_minready", str_to_num(str))
    get_vaultdata("cw_gametype", str, 63)
    set_cvar_num("xw_gametype", str_to_num(str))
    get_vaultdata("cw_maxrounds", str, 63)
    set_cvar_num("xw_maxrounds", str_to_num(str))
    get_vaultdata("cw_readymenu", str, 63)
    set_cvar_num("xw_readymenu", str_to_num(str))
    get_vaultdata("cw_gag", str, 63)
    set_cvar_num("xw_gag", str_to_num(str))
    get_vaultdata("cw_configs", str, 63)
    set_cvar_string("xw_configs", str)
    get_vaultdata("cw_period_number", str, 63)
    period_number = str_to_num(str)
    get_vaultdata("cw_status", str, 63)
    tmp = str_to_num(str)
    get_vaultdata("cw_password", war_password, 31)
    
    if(tmp>4) set_cvar_num("xw_knife_round", 0)
    status = (tmp<7) ? 1 : 7
    num_to_str(status, str, 63)
    set_vaultdata("cw_status",str)
    
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    
    gametype = get_cvar_num("xw_gametype")
    maxrounds = get_cvar_num("xw_maxrounds")
    minready = get_cvar_num("xw_minready")
    pl_recnum = 0
    
    war_warmup()
        
    return PLUGIN_CONTINUE
}

public war_delvaults(){
    #if defined DEBUG
    log_amx("* war_delvaults()")
    #endif
    remove_vaultdata("cw_initialized")
    remove_vaultdata("cw_map")
    remove_vaultdata("cw_team1")
    remove_vaultdata("cw_team2")
    remove_vaultdata("cw_score00")
    remove_vaultdata("cw_score01")
    remove_vaultdata("cw_score02")
    remove_vaultdata("cw_score10")
    remove_vaultdata("cw_score11")
    remove_vaultdata("cw_score12")
    remove_vaultdata("cw_tie")
    remove_vaultdata("cw_screenshots")
    remove_vaultdata("cw_demos")
    remove_vaultdata("cw_swapteams")
    remove_vaultdata("cw_ot_rounds")
    remove_vaultdata("cw_warmup_timelimit")
    remove_vaultdata("cw_knife_round")
    remove_vaultdata("cw_block_chooseteam")
    remove_vaultdata("cw_onlykillfrags")
    remove_vaultdata("cw_minready")
    remove_vaultdata("cw_gametype")
    remove_vaultdata("cw_maxrounds")
    remove_vaultdata("cw_readymenu")
    remove_vaultdata("cw_configs")
    remove_vaultdata("cw_period_number")
    remove_vaultdata("cw_status")
    remove_vaultdata("cw_password")
    remove_vaultdata("cw_gag")
    
    return PLUGIN_CONTINUE
}

public war_countdown(){
    #if defined DEBUG
    log_amx("* war_countdown(%d)", war_countdowntimer)
    #endif
    new players[32], numct, numt
    
    if(war_countdowntimer > 0){
        war_hudtext(MID_ALL,"hud_timer",1,1,3)
        war_countdowntimer--
        set_task(1.0,"war_countdown",TID_COUNTDOWN)
    }
    else {
        get_players(players, numct, "ce", "CT")
        get_players(players, numt, "ce", "TERRORIST")
        
        if(numct+numt == 0){
            #if defined LOG
            log_amx("%L", LANG_SERVER, "log_timerdisabled")
            #endif
            return PLUGIN_CONTINUE
        }
        
        war_forcestart(0)
    }
    
    return PLUGIN_CONTINUE
}

public war_setpassword(){
    #if defined DEBUG
    log_amx("* war_setpassword()")
    #endif
    get_cvar_string("sv_password", serv_password, 31)
    
    if((strlen(war_password) == 0) && (strlen(serv_password) > 0)) format(war_password, 31, "%s", serv_password)
    if(strlen(war_password) > 0){
        new players[32], num, i
        
        server_cmd("sv_password ^"%s^"", war_password)
        #if defined HLTV_SUPPORT
        if(hltv_address != -1){
            new  str[32]
            format(str, 31, "serverpassword ^"%s^"", war_password)
            war_hltvrcon(str)
            war_hltvread(AID_HREAD + 0)
        }
        #endif
        get_players(players, num, "ch")
        for(i=0;i<num;i++){
            client_cmd(players[i], "password %s", war_password)
            #if defined DEBUG
            log_amx("Client with id %d got password", players[i])
            #endif
        }
        war_clienttext(MID_CT, "clt_password")
        war_hudtext(MID_CT, "hud_password", 10, 1, 15)
        war_clienttext(MID_TER, "clt_password")
        war_hudtext(MID_TER, "hud_password", 10, 1, 15)
    }
    
    return PLUGIN_CONTINUE
}

public war_add2ini(file[32],newname[32]){
    #if defined DEBUG
    log_amx("* war_add2ini(%s,%s)",file,newname)
    #endif
    new inifile[256], text[32], len, pos=0, x=0
    
    format(inifile,255,"%s/%s", cfgdir, file)
    if (!file_exists(inifile)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_filenotfound", inifile)
        #endif
        return 0
    }

    while(read_file(inifile,pos++,text,31,len)){
        if(equali(text,newname)) return PLUGIN_CONTINUE
        x++
    }
    if(x < maxtagsini) write_file(inifile,newname)
    
    return PLUGIN_CONTINUE
}

public war_parsestrini1(tofind[],&r,&g,&b,&Float:x, &Float:y,&eff){
    #if defined DEBUG
    log_amx("* war_parsestrini1(%s)", tofind)
    #endif
    new inifile[64], text[128], len, timetmp[8], pos = 0, tmp[32], i, j
    
    format(inifile,63,"%s/strings.ini",cfgdir)
    if (!file_exists(inifile)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_filenotfound", inifile)
        #endif
        return -1
    }
    
    while(read_file(inifile,pos++,text,127,len)){
        if(contain(text,tofind) == 0){
            len = contain(text,"[")
            for(i=len+1;text[i]!=',';i++) tmp[i-len-1] = text[i]; tmp[i-len]=0; r = str_to_num(tmp)
            for(i=i+1,j=0;text[i]!=',';i++,j++) tmp[j] = text[i]; tmp[j]=0; g = str_to_num(tmp)
            for(i=i+1,j=0;text[i]!=',';i++,j++) tmp[j] = text[i]; tmp[j]=0; b = str_to_num(tmp)
            for(i=i+1,j=0;text[i]!=',';i++,j++) tmp[j] = text[i]; tmp[j]=0; x = floatstr(tmp)
            for(i=i+1,j=0;text[i]!=',';i++,j++) tmp[j] = text[i]; tmp[j]=0; y = floatstr(tmp)
            for(i=i+1,j=0;text[i]!=',';i++,j++) tmp[j] = text[i]; tmp[j]=0; eff = str_to_num(tmp)
            for(i=i+1,j=0;text[i]!=']';i++,j++) timetmp[j] = text[i]; timetmp[j]=0
            if(str_to_num(timetmp) == 0) return 0
            else return str_to_num(timetmp)
        }
    }
    
    return -1
}

public war_parsestrini2(tofind[]){
    #if defined DEBUG
    log_amx("* war_parsestrini2(%s)", tofind)
    #endif
    new inifile[64], text[128], len, end, timetmp[8], pos = 0, i
    
    format(inifile,63,"%s/strings.ini",cfgdir)
    if (!file_exists(inifile)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_filenotfound", inifile)
        #endif
        return -1
    }
    
    while(read_file(inifile,pos++,text,127,len)){
        if(contain(text,tofind) == 0){
            len = contain(text,"(")
            end = contain(text,")")
            if((end > len+4) || (end <= len+1)) return -1
            for(i=len+1;i<end;i++) timetmp[i-(len+1)] = text[i]
            if(str_to_num(timetmp) == 0) return 0
            else return str_to_num(timetmp)
        }
    }
    
    return -1
}

public war_tagreplace(id, textblock[textblock_size]){
    #if defined DEBUG
    log_amx("* war_tagreplace(%d)", id)
    #endif
    new half, hi[32], tname[2][32], tmp[64]
    
    if (status < 7 && status){
        half = 1
        format(hi, 31, "%L", id, "half1")
    }
    else{
        half = 2
        format(hi, 31, "%L", id, "half2")
    }
    if(strlen(t_name[0]) > 0){
        format(tname[0], 31, "%s", t_name[0])
        format(tname[1], 31, "%s", t_name[1])
    }
    else{
        format(tname[0], 31, "%L", id, "CTname")
        format(tname[1], 31, "%L", id, "Tname")
    }
    
    while(contain(textblock,"[lbrk]") != -1)        replace(textblock,textblock_size-1,"[lbrk]","^n")
    while(contain(textblock,"[CTname]") != -1)        replace(textblock,textblock_size-1,"[CTname]", tname[0])
    while(contain(textblock,"[Tname]") != -1)        replace(textblock,textblock_size-1,"[Tname]", tname[1])
    while(contain(textblock,"[ServerPassword]") != -1)    replace(textblock,textblock_size-1,"[ServerPassword]", war_password)
    while(contain(textblock,"[playedhalf]") != -1)        replace(textblock,textblock_size-1,"[playedhalf]",hi)
    while(contain(textblock,"[adminname]") != -1)        replace(textblock,textblock_size-1,"[adminname]", adminname)
    while(contain(textblock,"[whosready1]") != -1)        replace(textblock,textblock_size-1,"[whosready1]", whosready[0])
    while(contain(textblock,"[whosready2]") != -1)        replace(textblock,textblock_size-1,"[whosready2]", whosready[1])
    while(contain(textblock,"[players]") != -1){
        num_to_str(minready,tmp,3)
        replace(textblock,textblock_size-1,"[players]",tmp)
    }
    while(contain(textblock,"[maxrounds2]") != -1){
        format(tmp,15,"%i%s",maxrounds,(gametype==0) ? " + 1" : " * 2")
        replace(textblock,textblock_size-1,"[maxrounds2]",tmp)
    }
    while(contain(textblock,"[team1rdy]") != -1){
        num_to_str(p_ready[0],tmp,3)
        replace(textblock,textblock_size-1,"[team1rdy]",tmp)
    }
    while(contain(textblock,"[team2rdy]") != -1){
        num_to_str(p_ready[1],tmp,3)
        replace(textblock,textblock_size-1,"[team2rdy]",tmp)
    }
    while(contain(textblock,"[CTscore]") != -1){
        (half == 1) ? num_to_str(t_score[0][0],tmp,3) : num_to_str(t_score[1][0],tmp,3)
        replace(textblock,textblock_size-1,"[CTscore]",tmp)
    }
    while(contain(textblock,"[TERscore]") != -1){
        (half == 1) ? num_to_str(t_score[1][0],tmp,3) : num_to_str(t_score[0][0],tmp,3)
        replace(textblock,textblock_size-1,"[TERscore]",tmp)
    }
    while(contain(textblock,"[periodinfo]") != -1){
        if(period_number > 0) format(tmp,31," %L %i ",id,"OT",period_number)
        else format(tmp,31," ")
        replace(textblock,textblock_size-1,"[periodinfo]",tmp)
    }
    while(contain(textblock,"[round2]") != -1){
        num_to_str(t_score[0][half]+t_score[1][half]+1,tmp,3)
        replace(textblock,textblock_size-1,"[round2]",tmp)
    }
    while(contain(textblock,"[warmuptimer]") != -1){
        new m, s
            
        m = war_countdowntimer / 60
        s = war_countdowntimer - m * 60
        if(s>9)    format(tmp, 31, "%d:%d", m, s)
        else format(tmp, 31, "%d:0%d", m, s)
        replace(textblock,textblock_size-1,"[warmuptimer]",tmp)
    }
    while(contain(textblock,"[CaptainCT]") != -1){
        if(!captain_id[0]) format(tmp, 31, "...")
        else{
            get_user_name(captain_id[0], tmp, 31)
            war_removeclantag(tmp, 0)
        }
        replace(textblock,textblock_size-1,"[CaptainCT]",tmp)
    }
    while(contain(textblock,"[CaptainT]") != -1){
        if(!captain_id[1]) format(tmp, 31, "...")
        else{
            get_user_name(captain_id[1], tmp, 31)
            war_removeclantag(tmp, 1)
        }
        replace(textblock,textblock_size-1,"[CaptainT]",tmp)
    }
    
    return PLUGIN_CONTINUE
}

public war_clientshowtext(id, tofind[], type){
    #if defined DEBUG
    log_amx("* war_clientshowtext(%d, %s, %d)",id,tofind,type)
    #endif
    new textblock[textblock_size]
    
    if(is_user_hltv(id)) format(textblock, textblock_size-1, "%L", LANG_SERVER, tofind)
    else format(textblock, textblock_size-1, "%L", id, tofind)
    
    war_tagreplace(id, textblock)
    #if defined DEBUG
    log_amx("id:%d -> %s", id, textblock)
    #endif
    new str[textblock_size], x = contain(textblock, "^n")
    while(x > -1){
        copy(str, x, textblock)
        client_print(id, type, str)
        replace(textblock, textblock_size-1, str, "")
        replace(textblock, textblock_size-1, "^n", "")
        x = contain(textblock, "^n")
    }
    client_print(id, type, textblock)
    
    return PLUGIN_CONTINUE
}

public war_clienttext(id, tofind[]){
    #if defined DEBUG
    log_amx("* war_clienttext(%d, %s)",id,tofind)
    #endif   
    new type = war_parsestrini2(tofind)
    new players[32], num, i
    
    if((id == MID_CT) || (id == MID_ALL)){
        get_players(players, num, "ce", "CT")
        for(i=0;i<num;i++) war_clientshowtext(players[i], tofind, type)
    }
    
    if((id == MID_TER) || (id == MID_ALL)){
        get_players(players, num, "ce", "TERRORIST")
        for(i=0;i<num;i++) war_clientshowtext(players[i], tofind, type)
    }
    
    if((id == MID_SPEC) || (id == MID_ALL)){
        get_players(players, num, "ce", "SPECTATOR")
        for(i=0;i<num;i++) war_clientshowtext(players[i], tofind, type)
    }
    
    if(id > MID_ALL) war_clientshowtext(id, tofind, type)
    
    return PLUGIN_CONTINUE
}

public war_servertext(tofind[]){
    #if defined DEBUG
    log_amx("* war_servertext(%s)", tofind)
    #endif   
    new textblock[textblock_size]

    format(textblock, textblock_size-1, "%L", LANG_SERVER, tofind)
    war_tagreplace(0, textblock)
    server_print(textblock)

    return PLUGIN_CONTINUE
}

public war_hudshowtext(id, tofind[]){
    #if defined DEBUG
    log_amx("* war_hudshowtext(%d, %s)",id,tofind)
    #endif
    new textblock[textblock_size]
    
    if(is_user_hltv(id)) format(textblock, textblock_size-1, "%L", LANG_SERVER, tofind)
    else format(textblock, textblock_size-1, "%L", id, tofind)
    
    war_tagreplace(id, textblock)
    #if defined DEBUG
    log_amx("id:%d -> %s", id, textblock)
    #endif
    show_hudmessage(id,textblock)
    
    return PLUGIN_CONTINUE
}

public war_hudtext(id,tofind[],maxtime,mintime,screen){
    #if defined DEBUG
    log_amx("* war_hudtext(%d, %s, %d-%d, %d)", id, tofind, maxtime, mintime, screen)
    #endif   
    new r,g,b,eff, Float:x, Float:y
    new time = war_parsestrini1(tofind,r,g,b,x,y,eff)
    new players[32], num, i
    
    if(time == 0){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_timezero", tofind)
        #endif
        return 0
    }
    if((time < mintime) || (time > maxtime)){
        #if defined LOG
        log_amx("%L", LANG_SERVER, "log_timewrong", tofind, mintime, maxtime)
        #endif
        return 0
    }
    
    set_hudmessage(r,g,b,x,y, eff, 6.0, float(time), 0.2, 0.2, screen)
    
    if((id == MID_CT) || (id == MID_ALL)){
        get_players(players, num, "ce", "CT")
        for(i=0;i<num;i++) war_hudshowtext(players[i], tofind)
    }
    
    if((id == MID_TER) || (id == MID_ALL)){
        get_players(players, num, "ce", "TERRORIST")
        for(i=0;i<num;i++) war_hudshowtext(players[i], tofind)
    }
    
    if((id == MID_SPEC) || (id == MID_ALL)){
        get_players(players, num, "ce", "SPECTATOR")
        for(i=0;i<num;i++) war_hudshowtext(players[i], tofind)
        #if defined LOG
        new str[textblock_size]
        
        if(!equali(tofind, "hud_timer") && !equali(tofind, "hud_whosready")){
            format(str, textblock_size - 1, "%s:^n%L", tofind, LANG_SERVER, tofind)
            war_tagreplace(LANG_SERVER, str)
            log_amx(str)
        }
        #endif
    }
    
    if(id > MID_ALL) war_hudshowtext(id, tofind)
    
    return time
}

public war_scoreinfo(){
    #if defined DEBUG
    log_amx("* war_scoreinfo()")
    #endif
    war_hudtext(MID_SPEC, "hud_play1", 20, 2, 10)
    war_hudtext(MID_CT, "hud_play1a", 20, 2, 10)
    war_hudtext(MID_TER, "hud_play1b", 20, 2, 10)
    
    return PLUGIN_CONTINUE
}

public war_rr(time[]){
    #if defined DEBUG
    log_amx("* war_rr(%s)",time)
    #endif
    set_cvar_num("sv_restartround", str_to_num(time))
    
    return PLUGIN_CONTINUE
}

public war_swapteams(){
    #if defined DEBUG
    log_amx("* war_swapteams()")
    #endif
    new playersCT[32], playersT[32], nbrCT, nbrT, i
    
    get_players(playersCT,nbrCT,"e","CT")
    get_players(playersT,nbrT,"e","TERRORIST")
    
    for(i=0;i<nbrCT;i++) cs_set_user_team(playersCT[i], CS_TEAM_T)
    for(i=0;i<nbrT;i++)  cs_set_user_team(playersT[i], CS_TEAM_CT)
    
    war_rr("1")
    
    return PLUGIN_CONTINUE
}

public war_swapnames(id){
    #if defined DEBUG
    log_amx("* war_swapnames(id=%d)", id)
    #endif
    if (id && !((get_user_flags(id) & CMDACCESS))){
        war_clienttext(id, "clt_noaccess")
        return PLUGIN_HANDLED;
    }
    new str[32]
    
    format(str, 31, "%s", t_name[0])
    format(t_name[0], 31, "%s", t_name[1])
    format(t_name[1], 31, "%s", str)
    if((strlen(t_name[0])>0) && (strlen(t_name[1])>0)){
        set_vaultdata("cw_team1",t_name[0])
        set_vaultdata("cw_team2",t_name[1])
    }
    if(!id){
        new tmp = captain_id[1]
        captain_id[1] = captain_id[0]
        captain_id[0] = tmp
    }
    
    return PLUGIN_HANDLED
}

public war_ss(){   
    #if defined DEBUG
    log_amx("* war_ss()")
    #endif
    #if !defined POV_ADDDELAY
        #define POV_ADDDELAY 20
    #endif
    set_task(float(POV_ADDDELAY), "war_demo_off")
    if(get_cvar_num("xw_screenshots") == 0) return PLUGIN_CONTINUE           
    new players[32], num_players, i
    
    get_players(players,num_players, "ce", "CT")
    for(i=0;i<num_players;i++){
        client_cmd(players[i], "+showscores")
        
        set_task(0.3, "war_ss2", AID_SS2 + players[i])
        set_task(0.6, "war_ss3", AID_SS3 + players[i])
    }
    
    get_players(players, num_players, "ce", "TERRORIST")
    for(i=0;i<num_players;i++){
        client_cmd(players[i], "+showscores")
        
        set_task(0.3, "war_ss2", AID_SS2 + players[i])
        set_task(0.6, "war_ss3", AID_SS3 + players[i])
    }

    return PLUGIN_CONTINUE
}
public war_ss2(id) client_cmd(id - AID_SS2, "snapshot")
public war_ss3(id) client_cmd(id - AID_SS3, "-showscores")
public war_warmup_hud(id){
    #if defined DEBUG
    log_amx("* war_warmup_hud(%d)", id)
    #endif
    if(id > AID_WHUD) id -= AID_WHUD
    
    if(p_ready[0]+p_ready[1] > 0) war_hudtext(id, "hud_whosready",600,1,4)
    else {
        set_hudmessage(0,0,0, 0.0,0.0, 0, 1.0, 1.0, 0.2, 0.2, 4)    // remove whos ready msg
        show_hudmessage(0,".")
    }
    //aaa
    if((status==1) && (get_cvar_num("xw_knife_round")==1) && (period_number == 0)) war_hudtext(id,"hud_start2k",1000,0,10)
    else war_hudtext(id,"hud_start2",1000,0,10)
    
    return PLUGIN_CONTINUE
}

public war_clearready(){
    #if defined DEBUG
    log_amx("* war_clearready()")
    #endif
    for(new i=1;i<33;i++) readyplayers[i] = 0
    p_ready = {0,0}
    format(whosready[0],255,"")
    format(whosready[1],255,"")
    
    return PLUGIN_CONTINUE
}

public war_removeready(id){
    #if defined DEBUG
    log_amx("* war_removeready(%d)",id)
    #endif
    new playername[64], str[256], plteam = war_getuserteam(id)
    
    if(plteam == 2) return PLUGIN_HANDLED
    
    readyplayers[id] = 0
    get_user_name(id,playername,63)
    war_removeclantag(playername, plteam)
    
    p_ready[plteam]--
    format(str,255,", %s",playername)
    if(replace(whosready[plteam], 255, str, "")==0){
        format(str,255,"%s, ",playername)
        if(replace(whosready[plteam], 255, str, "")==0) replace(whosready[plteam], 255, playername, "")   
    }
    war_warmup_hud(MID_ALL)
    
    return PLUGIN_CONTINUE
}
public war_live_msg(){
    #if defined DEBUG
    log_amx("* war_live_msg()")
    #endif
    new str[16]
    
    war_hudtext(MID_ALL,"hud_start4",15,2,10)
    war_clienttext(MID_ALL, "clt_start1")
    status++
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    num_to_str(status, str, 15)
    set_vaultdata("cw_status",str)
    
    return PLUGIN_CONTINUE
}

public war_knife_msg(){
    #if defined DEBUG
    log_amx("* war_knife_msg()")
    #endif
    war_hudtext(MID_ALL,"hud_start4k",15,2,10)
    war_clienttext(MID_ALL, "clt_start1k")
    status = 3;    set_vaultdata("cw_status", "3")
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    
    return PLUGIN_CONTINUE
}

public war_onlyknife(){
    #if defined DEBUG
    log_amx("* war_onlyknife()")
    #endif
    new players[32],weapname[32],num_players,i
    
    get_weaponname(29,weapname,31)
    get_players(players,num_players,"e", "CT")
    for(i=0;i<num_players;i++){
        strip_user_weapons(players[i])
        give_item(players[i], weapname)
    }
    get_players(players,num_players,"e", "TERRORIST")
    for(i=0;i<num_players;i++){
        strip_user_weapons(players[i])
        give_item(players[i], weapname)
    }
    
    return PLUGIN_CONTINUE
}

public war_removeclantag(name[64], plteam){
    #if defined DEBUG
    log_amx("* war_removeclantag(%s, %d)", name, plteam)
    #endif
    if(strlen(t_name[plteam]) == 0) return PLUGIN_CONTINUE
    new x = containi(name, t_name[plteam]), str[64]
    if(x!=-1){
        copy(str,x,name)
        copy(str[x], 63,name[x+strlen(t_name[plteam])])
        copy(name, 63, str)
        trim(name)
        replace(name, 63, "|", "")
        trim(name)
    }

    return PLUGIN_CONTINUE
}

public war_getuserteam(id){
    new playerteam = 2
    
    switch(cs_get_user_team(id)){
        case CS_TEAM_CT: playerteam = 0
        case CS_TEAM_T: playerteam = 1
    }

    #if defined DEBUG
    log_amx("* war_getuserteam(%d), plteam:%d", id, playerteam)
    #endif

    return playerteam
}

public war_dorestart(mode){
    #if defined DEBUG
    log_amx("* war_dorestart(mode=%d)", mode)
    #endif
    war_demo_off()
    remove_task(TID_COUNTDOWN)
    remove_task(TID_ONLYKNIFE)
    remove_task(TID_RESTARTS)
    remove_task(TID_MSG)
    #if defined HLTV_SUPPORT
    remove_task(TID_HLTVREC)
    #endif
    if(status > 4) set_cvar_num("xw_knife_round", 0)
    new half = (status < 7) ? 1 : 2
    switch(mode){
        case 1: {
            new str[16]
            status = (status < 7) ? 1 : 7
            num_to_str(status, str, 15)
            set_vaultdata("cw_status",str)           
            #if defined DEBUG
            log_amx("**********************************************")
            log_amx("              status=%d", status)
            log_amx("**********************************************")
            #endif
            t_score[0][0] = t_score[0][0] - t_score[0][half]
            t_score[0][half] = 0
            t_score[1][0] = t_score[1][0] - t_score[1][half]
            t_score[1][half] = 0
        }
        case 2:{
            #if defined HLTV_SUPPORT
            if(hltv_status == 2) war_hltvstop()
            #endif
            server_cmd("sv_password ^"%s^"", serv_password)
            t_score[0] = {0, 0, 0}
            t_score[1] = {0, 0, 0}
            period_number = 0
            status = 1;    set_vaultdata("cw_status", "1")
            #if defined DEBUG
            log_amx("**********************************************")
            log_amx("              status=%d", status)
            log_amx("**********************************************")
            #endif
            if(half == 2){
                war_swapteams()
                war_swapnames(0)
            }
        }
    }
    #if defined DEBUG
    log_amx("**********************************************")
    log_amx("              status=%d", status)
    log_amx("**********************************************")
    #endif
    war_setvaults()
    war_warmup()
        
    return PLUGIN_CONTINUE
}

public war_setcaptains(team){
    #if defined DEBUG
    log_amx("* war_setcaptains(%d)", team)
    #endif
    new players[32], name[64], num, i
    
    (team == 0) ? get_players(players, num, "e", "CT") : get_players(players, num, "e", "TERRORIST")
    
    for(i=0;i<num;i++){
        get_user_name(players[i], name, 63)
        if(containi(name, CLANLEADERTAG)!=-1){
            captain_id[team] = players[i]
            break
        }
    }
    if(captain_id[team]==0) captain_id[team] = players[0]
    war_clienttext(captain_id[team], "clt_captain")
    war_hudtext(captain_id[team],"hud_captain",10,0,12)

    return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
 
Статус
В этой теме нельзя размещать новые ответы.

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу