local q1 = {"ܴĵְҵҽ⣬ʲôְҵ?(2)","ʿ"};
local q2 = {"ŷǿŷʲôϵ?","ֵ"};
--local q3 = {"µӢʲôдĸ","mario"};
--local q4 = {"ħèͷӥͷļ۸Ƕ٣شּ","12"};
local q5 = {"ʬĸϵĳ?(Ʃ硰ϵ)","ϵ"};
local q6 = {"ڿڴֻУȿǷʹʯشԻ򲻿ԣ",""};
local q7 = {"ӡʦְҵĵ⼼ʲô(ȫ)","Լ"};
local q8 = {"ĸְҵĵ⼼(ȫ)",""};
local q9 = {"οСڣ(Сд,ctrl+c)","ctrl+s"};
local q10 = {"Ŀݼǣ(Сд,ctrl+c)","ctrl+e"};
local q11 = {"ħ,ʼɫĿɷǣ(ֱӻش)","30"};
local q12 = {"                 ˭شȫ",""};
local q13 = {"ţҪԲܲɼ?(ش)","5"};
local q14 = {"Ҫھܲɼ?ش֣","5"};
local q15 = {"֮˭","ˮʮ"};
local q16 = {"ħѧϰ似Ҫħ?(ֱӻش)","100"};
--local q17 = {"ټܹʹ?","10"};
--local q18 = {"ǳ˵ֽʲô","ŷǿ"};
--local q19 = {"ԭϲݺһʲô","һһ"};
local q20 = {"ÿ1,ɹɷĵǼ?(ֱӻش)","4"};
local q21 = {"һǼ?(ֱӻش)","5"};
local q22 = {"жٸҽԺ(ֱӻش)","2"};
local q23 = {"ħĿǰ֧32λϷ?(ֱӻش֧֡򡰲֧֡)","֧"};
local q24 = {"ħӢ?(Ҫո,ʹСд)","crossgate"};
--local q25 = {"ܹ۳ħļܽʲô","սϮ"};
local q26 = {"ħиʿҪļǣ",""};
local q27 = {"ְְҵ,Ҫʲô?(ȫ)","Ů"};
local q28 = {"ƺš֪ˡͨʲôõ..(ȫ)","ɭ"};
local q29 = {"ħϵ2תҪȴ2Сʱ?(ֱӻشҪ򡰲Ҫ)","Ҫ"};
local q30 = {"ְʦְҵ,ҪܵBossʲô?(ȫ)","¶"};
local q31 = {"ƺš˵еߡͨĸBossõ?(ȫ)","̴"};
local q32 = {"ƺš֮ߡͨĸõ?(ȫ)","Ĭ֮"};
local q33 = {"ÿ챻Űε˽ʲô",""};
local q34 = {"׳12Ĵȷֽʲô?(ȫ)",""};
local q35 = {"άŵǴλĿ½?(ȫ,Ʃ硰xxx½)","ܽŴ½"};
local q36 = {"ľNPCʲô",""};
local q37 = {"ɴзMpļܽʲô?","սϮ"};
local q38 = {"ħBOSSȼ͵Թʲô","ϼ֮"};
local q39 = {"Ϸ񸸡У׵ֵֽʲô)",""};
local q40 = {"ְҵ,߿Դﵽټ","10"};
--local q41 = {"ϵмǷڼϰ?(ֱӻش𡰿ԡ򡰲ԡ)",""};
local q42 = {"ְʱ,õĵһƺʲô?(ȫ)",""};
local q43 = {"ְҵĵ⼼ʲô?(ȫ)",""};
local q44 = {"ְ̽ҵĵ⼼ʲô?(ȫ)","װ"};
local q45 = {"ħԷħ֮ŭôشԻŲ",""};
local q46 = {"ྻħĸְҵĵ⼼?(ȫ)","ʦ"};
local q47 = {"Ҫѧϰ,ҪĸNpcѧϰ",""};
local q48 = {"Կĸ?()","ˮ"};
local q49 = {"ˮԿĸ?()",""};
local q50 = {"LZSBĴʲô","ձ"};
local q51 = {"10Cȫʲô","С"};
local q52 = {"ڡʥʿʸУһԵʥʲôҪشXX",""};
local q53 = {"ޱʲô","5ɵ5"};
local q54 = {"ϵȫʲô?(Ҫϵ)","ϵ"};
local q55 = {"CS1.6УTAWPĿݼʲôдĸ","B45"};
local q56 = {"CS1.6УCTAWPĿݼʲôдĸ","B46"};
local q57 = {"Ԫ˭","˹"};
local q58 = {"֮ﶯпѵCV˭",""};
local q59 = {"ҲںûǮΪ϶ûǮ˭˵","˼"};
local q60 = {"³ɹꣿشּ","2001"};
local q61 = {"Ĺ˾ܲ","ʥǸ"};
local q62 = {"ħжٸ?(ֱӻشּȿ)","9"};
local q63 = {"ˮʲô?(:ˮ55)","ˮ82"};
local q64 = {"˭ģ",""};
local q65 = {"ʯʲô?(:ˮ55)","37"};
local q66 = {"ʲô?(:ˮ55)","37"};
local q67 = {"Ʒʲô?(:ˮ55)","73"};
local q68 = {"ɱЫʲô?(:ˮ55)","9ˮ1"}
local q69 = {"Ŀʲô?(:ˮ55)","46"};
local q70 = {"ôɰһǡ","к"};
--local q71 = {"ɽǵʲô","ң"};
--local q72 = {"ܹ鵽QĲƱʲôƱȫ","ʯƱ"};
--local q73 = {"ǰǵĴֻĴǶ?(ֱӻش)","500"};
--local q74 = {"Ҫ֮ҪʲôBOSS","˹"};
--local q75 = {"ת֮Ĵ󹫼Яļܽʲô","аħϮ"};
--local q76 = {"ҪֹʹҩǸNPCۣһ֣",""};
--local q77 = {"ħУҪټſԽӵ񣿣شּɣ","110"};
--local q78 = {"ڿǱУǷд򿨵NPCشлûУ","û"};
--local q79 = {"ʿʯӵϻʲô",""};
local q80 = {"ħ2.0ʱڵİ汾ʲô?","˵е"};
local q81 = {"ħ2.5ʱڵİ汾ʲô?","¾"};
local q82 = {"ħ3.0ʱڵİ汾ʲô?","֮˵"};
local q83 = {"ħ3.5ʱڵİ汾ʲô?",""};
local q84 = {"ħ3.7ʱڵİ汾ʲô?","֮ɳ©"};
local q85 = {"ħ1.5ʱڵİ汾ʲô?","޴"};
local q86 = {"ÿ1,ɹɷĵǼ?(ֱӻش)","1"};
local q87 = {"ħУת֮1ӵеԵǶ٣ش","110"};
local q88 = {"Ժڷǵʲôطٻ?ش","ʥ"};
--local q89 = {"ħʲôʱ򿪷?(:200174)","2014228"};
local q90 = {"֮ǹͨĸBoss",""};
local q91 = {"³˹֮ͨĸBoss",""};
local q92 = {"̯ϵͳҪٷ֮ٵ˰شּɣ","1"};
local q93 = {"ħʷ,ĸһԷɱ50000+˺",""};
local q94 = {"ϷǷӳ＼ĵ?(ֱӻش𡰴ڡ򡰲ڡ)",""};
local q95 = {"սĸͼ֮(شȫ)","ɳĮ֮"};
--local q96 = {"ﴫ˵Уǵñӵɫǣ","ɫ"};
local q97 = {"ƺš૵ĸ֮ʲôƺ?(شȫ)","ϵӰ"};
--local q98 = {"ǧ֮Ҫǣ","㷹"};
local q99 = {"ΰǵʲô","ַ"};
local q100 = {"ڵ۹ʱ1СĴʼֵǶ٣شּ","40"};
local q101 = {"뱦ڶУVEXĺ˭","ɳ"};
local q102 = {"Ǽ1.07汾УսʿĻֵǶ٣شּ","80"};
local q103 = {"ZERO3ȫܽŲװҪܾʲôBOSSã","̽"};
local q104 = {"Ǵʱ450㿨ۼǶңشּ","30"};
local q105 = {"ڿڴֽ&УǷͨ;ðɻɳɣشԻ߲",""};
local q106 = {"FC汾ĳ3С1-3ؿȴԽطѡصӣشּ","288"};
local q107 = {"MD汾ΰУǷشǻ񼴿",""};
local q108 = {"ջʲô",""};
local q109 = {"2,5,7,13,17,23,24,41,43ЩĸֺĲһ","24"};
local q110 = {"ȫʲô","¶ŵ"};
--local q111 = {"ħ7ųٵش֣","7"};
--local q112 = {"ħУ5佫֧ᷢ","9"};
local q113 = {"︽Կٽ뾺(:ҽԺ)","и"};
local q114 = {"ޡѡ˹׳ʲô(ôдĸش)","BBA"};
--local q115 = {"ͨ˵Ĺȫǣ","ֵĶ"};
--local q116 = {"ħħĹٷҳǶ","www.lmmoli.com"};
--local q117 = {"6ӦǶ٣","13"};
--local q118 = {"ϷLeft 4 Dead 2СսģʽͨѶTANKѪǶ٣ش","4000"};
--local q119 = {"սϵĶתƺŽʲô","֮"};
--local q120 = {"ϵһתƺʲô","֮"};
local q121 = {"HPȫʲô","health point"};
local q122 = {"ÿ1Ӷشּ","8"};
--local q123 = {"ڻ궷-У԰Ŷʱըʲôд","beans"};
local q124 = {"ħħʯԶ?(شԻ򲻿Լɣ",""};
local q125 = {"ٷӽĽʽǣģ","¶"};
--local q126 = {"ʿܶϿն10۳Ĺٷ֮٣ش֣","40"};
local q127 = {"ֽ˵ӽ?","ζ"};
local q128 = {"èײʱꣿXXش","1940"};
local q129 = {"һֻʲôɫĴ⬣شXɫ","ɫ"};
local q130 = {"ϷϽװ𣺸𡷵˹ʲô","׵"};
local q131 = {"ԯ⴫֮Уװ֮¿ָʲô",""};
local q132 = {"SEGA˾ļûMDȫʲôд","MEGA DRIVE"};
local q133 = {"׳ƵĿţĵͼֽʲô","˹"};
local q134 = {"ܾԹλشּ","5"};
local q135 = {"FC汾̹˴սУÿһؿо̹ǣش","20"};
local q136 = {"ǼУMarineĳʼǶ١شּ","6"};
local q137 = {"˹̹һùŵ()","1"};
local q138 = {"Csʲô",""};
local q139 = {"þԪصǶ٣شּ","12"};
local q140 = {"Σ3УҩCCԵʲôӵ","䶳"};
local q141 = {"ڵУǺΨһֵһش(ӢСд)","tan"};
local q142 = {"Sڶʲôشƴ","ti"};
local q143 = {"1+6*3-1=شּ","18"};
local q144 = {"ħ񣬵õĳʲô",""};
local q145 = {"ͨάŵǵĺͨսϵҪټſԽ룬شּ","20"};
local q146 = {"ħУͨŵߵĺͨټԽ룬شּ","25"};
local q147 = {"Ϊµ·?()","2"};
local q148 = {"èëɫǣشXɫ","ɫ"};
local q149 = {"ֶУֱĵʲô","Ÿ"};
local q150 = {"ѧϰѪ1Ĵֽʲô","ʥ³"};
local q151 = {"ͨʲôõģ","ˮ֩"};
local q152 = {"̰ͨʲôBOSSģ","콩ʬ"};
local q153 = {"ĸʲôҪֵشɣ","ɱ"};
local q154 = {"ħУBOSS㽶һԹ","ϼ֮"};
local q155 = {"ش⣬Ҫʲô","/a"};
local q156 = {"ħԼֱαһվֱģ",""};
local q157 = {"ħУдǿԴҳģҲôشԻ߲",""};
local q158 = {"Ԩһжٲ㣿شּ","50"};
local q159 = {"3תʦǿָħߵȼǣشּ","4"};
local q160 = {"۹ʱӢļǣӢĴд3ĸ","AOE"};
local q161 = {"һˮģ",""};
local q162 = {"ڷɫ3&4бΪ漣ʲô",""};
local q163 = {"֮3У׿ӶٵĻֵشּ","50"};
local q164 = {"ļӣֱΪʲô",""};
local q165 = {"ħУʿѧϰ߿Եټش","10"};
local q166 = {"ڰƻ2Улܲ·ȼʲôСдĸ","r"};
local q167 = {"CMDУٲѯԵǣ","ipconfig"};
local q168 = {"𽢵ĵֱַ죬磬һʲô",""};
local q169 = {"3תսʿߵȼΪشּ","6"};
local q170 = {"ħǧ֮еõޣظǼӶٵģشּ","30"};
local question = {q1,q2,q5,q6,q7,q8,q9,q10,q11,q12,q13,q14,q15,q16,q20,q21,q22,q23,q24,q26,q27,q28,q29,q30,q31,q32,q33,q34,q35,q36,q37,q38,q39,q40,q42,q43,q44,q45,q46,q47,q48,q49,q50,q51,q52,q53,q54,q55,q56,q57,q58,q59,q60,q61,q62,q63,q64,q65,q66,q67,q68,q69,q70,q80,q81,q82,q83,q84,q85,q87,q88,q89,q90,q91,q92,q93,q94,q95,q96,q97,q99,q100,q101,q102,q103,q104,q105,q106,q107,q108,q109,q110,q113,q114,q121,q122,q124,q125,q127,q128,q129,q130,q131,q132,q133,q134,q135,q136,q137,q138,q139,q140,q141,q142,q143,q144,q145,q146,q147,q148,q149,q150,q151,q152,q153,q154,q155,q156,q157,q158,q159,q160,q161,q162,q163,q164,q165,q166,q167,q168,q169,q170};
local Q_status = 0;
--0:δʼ 1:׼ 2:ʼ 3:ȴ
local ans_list = {};
local PTime = 0;
local rn = 0;
local rb = 0;
local lastQTime = os.time();
local MeTime = 0;
local Q_T_Rand = 0;
local Q_A_Rand = 0;

local nowQuestionNum = 0;

Delegate.RegInit("question_Init");


function Myinit(_MeIndex)
	return true;
end


function initque_referee()
	if (que_referee == nil) then
		que_referee = NL.CreateNpc("lua/Module/question.lua", "Myinit");
		Char.SetData(que_referee,%_%,101003);
		Char.SetData(que_referee,%_ԭ%,101003);
		Char.SetData(que_referee,%_X%,20);
		Char.SetData(que_referee,%_Y%,20);
		Char.SetData(que_referee,%_ͼ%,777);
		Char.SetData(que_referee,%_%,4);
		Char.SetData(que_referee,%_%,"");
		NLG.UpChar(que_referee);
		Char.SetLoopEvent("lua/Module/question.lua", "questionLoop", que_referee, 1000);
	end
end



function question_Init()
	
	initque_referee();
	
end


Delegate.RegDelTalkEvent("question_talk_Event");

function question_talk_Event(player,msg,color,range,size)


	if(check_msg(msg,"/a"))then
		    --NLG.SystemMessage(player,Char.GetData(player,%_GM%));
		checkAns(player,msg);
	end	


	local gmpassword = "xx1ml";
	if(check_msg(msg,"["..gmpassword.." showquest]") or check_msg(msg,"["..gmpassword.." ShowQuest]")) then
			questStart();
	end
    if(check_msg(msg,"["..gmpassword.." startquest]") or check_msg(msg,"["..gmpassword.." StartQuest]")) then
			questOpen = 1;
            NLG.SystemMessage(player,"Ѿ˴ϵͳ");
	end
    if(check_msg(msg,"["..gmpassword.." endquest]") or check_msg(msg,"["..gmpassword.." EndQuest]")) then
			questOpen = 0;
            NLG.SystemMessage(player,"Ѿر˴ϵͳ");
	end

end

function Init(index)
	return true;
end

function questionLoop(index)
	
        if (questOpen ==0)then
           return;
        end

        --δʼ
	MeQTime = os.time();
	Q_T_Rand = math.random(1,1001);
	if(Q_T_Rand > 950 and Q_status == 0 and MeQTime - lastQTime >= 1800) then
		lastQTime = os.time();
		Q_status = 1;
		ans_list = {};
	end
	if(Q_status==0) then
		return;
	end
	--ϵͳ,׼
	if(Q_status==1) then
		NLG.SystemMessage(-1,"[]ʼ,֪ĿĴ,/a 𰸲ʽȿ!");
		ans_list = {};
		Q_status = 2;
	end
	--
	if(Q_status==2) then
		Q_status = 3;
		ans_list = {};
		r = math.random(1,170-15);
		nowQuestionNum = r;
		PTime = os.time();
		--print(os.time());
		--PTimeH = nowTime["hour"];
		--PTimeM = nowTime["min"];
		NLG.SystemMessage(-1,"[]ĿΪ:"..question[r][1]..",ӻԾ!");
		return;
	end
	--ȴ
	if(Q_status==3) then
		local nowTime = os.time();
		if(ans_list[1]~=nil and nowTime - PTime>=60) then
			Q_A_Rand = math.random(1,2);
			if(Q_A_Rand == 2 or Q_A_Rand == 1) then
				--rb = math.random(NLG.GetPlayerNum(),NLG.GetPlayerNum() * Char.GetData(ans_list[1],%_ȼ%));
				--NLG.SystemMessage(-1,"ϲ["..Char.GetData(ans_list[1],%_%).."]ɹ!ý"..rb.."!");
				Char.GiveItem(ans_list[1],192451,1);
				NLG.TalkToCli(ans_list[1],index,"ϲ["..Char.GetData(ans_list[1],%_%).."]ɹ!",%ɫ_ɫ%,%_%);
			end
			if(Q_A_Rand == 3) then
				local QPetExp;
				rb = math.random(NLG.GetPlayerNum(),NLG.GetPlayerNum() * Char.GetData(ans_list[1],%_ȼ%));
				NLG.SystemMessage(-1,"ϲ["..Char.GetData(ans_list[1],%_%).."]ɹ!ý"..rb.."ﾭ!");
				for QPetExp=0,5 do
					local Pet_In = Char.GetPet(ans_list[1],QPetExp);
					if (Pet_In ~= 0) then
						--local Pet_In2 = Char.GetData(Pet_In,1);
						local Pet_Lv = Char.GetData(Pet_In,%_ȼ%);
						if( Pet_Lv ~= 120 and Pet_Lv >= 10) then
							local Pet_Exp = Char.GetData(Pet_In,%_%);
							if(Pet_Exp == nil) then
								Pet_Exp = 0;
							end
							local Pet_Exp2 = Pet_Exp + rb;
							Char.SetData(Pet_In,%_%,Pet_Exp2);
							NLG.TalkToCli(ans_list[1],index,"ĳ"..Char.GetData(Pet_In,%_%).."ý "..rb.." Exp!",%ɫ_ɫ%,%_%);
							Pet.UpPet(ans_list[1],Pet_In);
						else
							NLG.TalkToCli(ans_list[1],index,"ĳ"..Char.GetData(Pet_In,%_%).."Ի"..rb..",򲻷,鱻Զ..",%ɫ_ɫ%,%_%);
						end
					end
				end
			end
			Q_status = 0;
			PTime = 0;
		end
		if(nowTime -PTime == 60 and Q_status ~= 0) then
		--if(ans_list[1]==nil and nowTime - PTime ==60) then
			Q_status = 0;
			PTime = 0;
			NLG.SystemMessage(-1,"[]ǧ,һ˻شҵ?");
		end
	end
end

function questStart()
	Q_status = 2;
end

function checkAns(PlayA,msg)
	if(Q_status~=3)then
		NLG.TalkToCli(PlayA,0,"δʼŶ!");
		return;
	end
	if(Q_status==3)then
		NLG.TalkToCli(PlayA,0,"ĴѾ¼,ȴ!",%ɫ_ɫ%,%_%);
	end
	--print("/a "..question[r][2].."|"..msg);
	if(msg == "/a "..question[nowQuestionNum][2])then
		table.insert(ans_list,PlayA);
	end
end