-	script	Anti_Bot	-1,{


//===========================================================================
//===== Configurações: ======================================================

OnInit:

set .npc$, "^00B2EE[Security AntiBot]^000000";	//

//===========================================================================
//= Character ban time when canceling / making a wrong answer (Minutes)
//===========================================================================

set .bantime,5;

//===========================================================================
//= Number of chances that the player has to answer the questions.
//===========================================================================

set .chances,5;

//===========================================================================
//= Minimum account level for the anti-bot to perform checks.
//===========================================================================

set .NvMax,0;

//===========================================================================
//= Minimum number of monsters that must be killed to activate the script.
//===========================================================================

set .MinMonster,rand(100,300);

//===========================================================================
//= Color options in the menu.
//===========================================================================

setarray .cores$,	" Blue",
					" Red",
					" Black",
					" Orange",
					" Yellow",
					" Green";
					
set .arraysize,getarraysize(.cores$);

//===========================================================================
//= NPC's speech color. (Advisable not to touch here)
//===========================================================================

setarray .cores2$,	"^006eff",	// Azul
					"^ff000a",	// Vermelho
					"^000000",	// Preto
					"^fd680d",	// Laranja
					"^b69800",	// Amarelo
					"^41ad00";	// Verde

//===========================================================================
//= Questions asked in case of verification 1. (Just complete the question)
//===========================================================================

setarray .imges$,	"bat_kiyom1",
					"bat_crua1",
					"bard_eland01",
					"hair_f_22",
					"hair_f_12",
					"hair_f_19",
					"kh_kiel01",
					"lhz_diguts02",
					"lhz_diguts02",
					"prt_soldier",
					"wish_maiden11",
					"oliver_hum";

//===========================================================================
//= Perguntas feitas no caso da verificação 2. (Apenas complemente a pergunta)
//===========================================================================

setarray .pergs$,	"of the cover",
					"of the cover",
					"of the hat",
					"of hair",
					"of shoes",
					"of hair",
					"of clothing",
					"of the tie",
					"of the pants",
					"of the hat",
					"of the wings",
					"of hair";

//===========================================================================
//= Número da cor que responde corretamente à pergunta.
//===========================================================================

setarray .resps2,0,1,5,0,3,5,0,1,0,3,2,4;

//===========================================================================
//= Checagem no Login:
//===== IMPORTANTE: =========================================================
//= Uncomment: "OnPCLoginEvent" if you want the npc to always be
//= activated when the character accesses the server.

end;

//OnPCLoginEvent:
//===== End of Settings: ==============================================
//===========================================================================
//===== Script Start: ===================================================
	
	set #antibot,.MinMonster;
	
    OnNPCKillEvent:
		if(set(#antibot,#antibot+rand(2))<.MinMonster) end;
		set .@opt,(checkcart()?128:0)|(checkriding()?32:0)|(checkfalcon()?16:0);
		set @AccLv,getgmlevel();
		atcommand "@option 1 4 2";
		setoption 0x40,1;
		attachnpctimer;
		initnpctimer;
	
	mes .npc$;
    mes (gettime(3)>= 6&&gettime(3)<= 12?"Good Morning":(gettime(3)>=13&&gettime(3)<=18?"Good Afternoon":"Good Night"))+", ^FFA500"+strcharinfo(0)+"^000000! To avoid malicious players, I need to test you...";
    
	while(1){
        next;
        set .@menu$,"";
        mes .@nome$;
		
        for(set @i,0;@i<.arraysize;set @i,@i+1){
            set .@num[@i],rand(.arraysize);
            for(set @o,0;@o<@i;set @o,@o+1)
                if(.@num[@i]==.@num[@o]){
					set .@num[@i],rand(.arraysize); set @o,-1;
				}
        }
		
        if(rand(2)){
			mes .npc$;
            mes "What is the color "+.pergs$[set(.@num2,rand(getarraysize(.resps2)))]+" of the character in the illustration displayed on your screen?";
            cutin .imges$[.@num2],rand(5);
            set @resps,.resps2[.@num2];
        }else{
			mes .npc$;
            mes .cores2$[set(@resps,rand(.arraysize))]+"What color is currently being used in my speech? Select the correct color from the menu:";
        }
		
        for(set @i,0;@i<.arraysize;set @i,@i+1){
            //mes .cores2$[@i]+.cores$[@i];
            set .@menu$,.@menu$+"^3CB371[>]^000000" +.cores$[.@num[@i]]+":";
        }
		
        next;
        if(prompt(.@menu$)==255) {
			atcommand "@kick "+.bantime+"mn "+strcharinfo(0);
			end;
		}
		
        mes .@nome$;
        if(.@num[@menu-1]!=@resps){
            if(set(.@tentvs,.@tentvs+1) >= .chances){
				cutin "",255;
				mes .npc$;
				mes "^FF0000Suspicious activity detected! ^000000 For security reasons you will be disconnected from the server.";
				atcommand "@option 0 0 "+.@opt;
				atcommand "@kick "+strcharinfo(0)+"'";	
                end;
            }
			
			mes .npc$;
            mes "^FF0000Incorrect answer!^000000 You still own ^ff0000"+(.chances-.@tentvs)+"^000000 attempts.";
            cutin "",255;
            continue;
        }
		
		mes .npc$;
        mes "^3CB371Right answer!^000000 Thanks for answering the question, have a great game.";
        cutin "",255;
        setoption 0x40,0;
        atcommand "@option 0 0 "+.@opt;
        set #antibot,0;
        stopnpctimer;
        close;
    }
	end;

//===== End of Scriptt: ======================================================
//===========================================================================
//===== Check Response Time: (segundos*1000) ======================

	OnTimer60000:
        atcommand "@kick "+strcharinfo(0);
        end;
		
//===== End of Check: ====================================================
//===========================================================================
		
}