-----------------------------------------------------------------------------------
------ƥ-------

--ű
ѵǼǵص =ѵǼǵص or {}	----¼ڵǼǵص
PrtJiLu = PrtJiLu or {}			--ʱָ
ƥ=ƥ or  {}
ʱ¼ = ʱ¼ or {}			--ʱָ
ƥ䴴 = ƥ䴴 or {}		--¼ƥбʽ{ص,ȼ,,{ң..}}
PlayerTime ={}					----ҽ׼״̬ = 0Ǵ׼ >0ǵȴ״̬
WarpPlayerNum=WarpPlayerNum or {}				--¼{ص=} >=5ʼ
ƥб= {}
ʱͼ¼={}
local ֮ʯid=123456
	--ʽ |Ƶȼ|շ|  ơƴ͵ID 0 ƵڵIDǰ -
local Ŵ͵ͼ= {"|10|100|0,1538,16,7|0",
		"|10|300|0,100,589,47|96|ش",
		"|10|700|0,33000,290,436|0",
		"ѩɽ|30|800|0,402,83,193|102|˹崫",
		"׶|40|800|0,15595,12,12|97|άŵǴ崫",
		"ˮ|50|1000|0,15542,17,24|97|άŵǴ崫",
                "ɽ|70|800|0,36003,11,2|0",
                "ɽ|70|2000|0,48000,25,27|-16389|Ʒָ֮",
                "ɳ̲|90|2000|0,30002,404,94|163|ŷȴ",}

-----------------------------------------------------------------------------------
--                 NPCá
------------------------------------------------------------------------------
local NpcName = "ٻԱ"					--NpcƣͬʱҲǽűƣ
local NpcMapPos = {0, 1000, 236, 83}		--Npcͼ
local NpcImage = 106602					--Npcͼ101022
local NpcDir = 4						--Npc0Ϊϣ˳ʱת
Delegate.RegInit("EasyWarpNPC_Init");
function EasyWarpNPC_Init()

	local ƥNPC = CreateNpc("ƥNPC")
	Char.SetData( ƥNPC, .., NpcImage);
	Char.SetData( ƥNPC, ..ԭ, NpcImage);
	Char.SetData( ƥNPC, ..ͼ, NpcMapPos[1]);
	Char.SetData( ƥNPC, ..ͼ, NpcMapPos[2]);
	Char.SetData( ƥNPC, ..X, NpcMapPos[3]);
	Char.SetData( ƥNPC, ..Y, NpcMapPos[4]);
	Char.SetData( ƥNPC, .., NpcDir);
	Char.SetData( ƥNPC, ..ԭ, NpcName);
	NLG.UpChar(ƥNPC)
	Char.SetTalkedEvent(nil, "EasyWarpNPC_Talked", ƥNPC)
	Char.SetWindowTalkedEvent(nil, "EasyWarpNPC_WindowTalked", ƥNPC)
	Char.SetLoopEvent(nil, "Warp_LoopEvent", ƥNPC,10);--30һǷ
	if #WarpPlayerNum==0 then
		WarpPlayerNum={}
		for i=1,#Ŵ͵ͼ do
			WarpPlayerNum[i]={}
		end
	end
	return true;
end
function EasyWarpNPC_Talked( _MeIndex, _PlayerIndex, _Mode)
if(NLG.CheckInFront(_PlayerIndex, _MeIndex, 1) == false) then--Ƿǰ
		return ;
	end 

	NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, 2, 999,
			"5\nƥ" ..
			"\n" ..
			"\nӭʹ[ƥ]ϵͳϵͳ˵£" ..
			"\n1ҿѡص㣬" ..
			"\n2֪ᷢͨ" ..
			"\n   С" ..
			"\n   С" ..
			"\n   ѯѡ" ..
			"\n   ȡǼǡ" ..
			"\n");
		PrtJiLu[_PlayerIndex] = nil
	return ;
end

function EasyWarpNPC_WindowTalked( _MeIndex, _PlayerIndex, _Seqno, _Select, _Data)
		local tName= Char.GetData(_PlayerIndex,%_ԭ%)
		local tLevel= Char.GetData(_PlayerIndex,%_ȼ%)
		local CdKey= Char.GetData(_PlayerIndex,2002)
	if _Select == 2 and _Seqno~=999 then ---˳
	NLG.ShowWindowTalked(_PlayerIndex,
			_MeIndex, 2, 2, 999,
			"5\nƥ" ..
			"\n" ..
			"\nӭʹ[ƥ]ϵͳϵͳ˵£" ..
			"\n1ҿѡص㣬" ..
			"\n2֪ᷢͨ" ..
			"\n   С" ..
			"\n   С" ..
			"\n   ѯѡ" ..
			"\n   ȡǼǡ" ..
			"\n");
			PrtJiLu[_PlayerIndex] = nil
		return ;
	end
	-----
	if _Seqno == 999 then
		if _Data == "1" then--
			if ѵǼǵص[_PlayerIndex]==nil then
			PrtJiLu[_PlayerIndex] = 0
			ʱ¼[_PlayerIndex]=1
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, 34, PrtJiLu[_PlayerIndex],鴰(_PlayerIndex,PrtJiLu[_PlayerIndex],Ŵ͵ͼ));
			---鿴б
			else
				NLG.SystemMessage(_PlayerIndex,"[ϵͳ]ǰѾǼǹƥҪµ¼ȡǼ")
			end
			return ;
		end
		if _Data == "2" then
			--鿴ж
			PrtJiLu[_PlayerIndex] = 0
			if #ƥ䴴==nil then
				NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,String.Centering("\n\n\n\nǰûеǼǴͼ¼"));
				return ;
			end
			ƥб[_PlayerIndex]={}
			for k,v in pairs(ƥ䴴) do
				table.insert(ƥб[_PlayerIndex],{k,v})
			end
			local tselect =34
			if #ƥб[_PlayerIndex] < 6 then
				tselect=2
			end
			ʱ¼[_PlayerIndex]=2
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, tselect, PrtJiLu[_PlayerIndex],鿴鴰(_PlayerIndex,PrtJiLu[_PlayerIndex]));
			return ;
		end
		if _Data == "3" then
			--ʾƥ
			if ѵǼǵص[_PlayerIndex]~=nil then
				NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, 2,888,ȡƥ(_PlayerIndex));
			else
				ʱ¼[_PlayerIndex]=2
				NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\nûļ¼Ϣ");
				NLG.SystemMessage(_PlayerIndex,"[ϵͳ]㲢ûм¼Ϣ")
			end
			return ;
		end
		if _Data == "4" then 
			---˼¼
			if ѵǼǵص[_PlayerIndex]==nil then
				NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,String.Centering("\n\n\n\n㲢ûм¼ַ"));
				NLG.SystemMessage(_PlayerIndex,"[ϵͳ]㲢ûм¼Ϣ")
			else
				DelWarpPlayer(_PlayerIndex)
				return ;
			end
		end
	end

	
	if tonumber(_Seqno) ==888 and  tonumber(_Data)==1 then----------ϵͳ㲥
		if GetGold(_PlayerIndex)> 500 then
			local ӳCdKey=ѵǼǵص[_PlayerIndex]
			local ص=ƥ䴴[ӳCdKey][1]
			local Warp = Split(Ŵ͵ͼ[ص],"|");
			local շ = tonumber(Warp[3]);
			local Ҫȼ= ƥ䴴[ӳCdKey][2]
			local =ƥ䴴[ӳCdKey][3]
			local =#ƥ[ӳCdKey]
			local ͼ =Warp[1]
			Char.AddGold(_PlayerIndex,-500); 
--		local money = Char.GetData(_PlayerIndex,%_%);
--			Char.SetData(_PlayerIndex,%_%,money-500);
--			NLG.UpChar(player);			
			local EventName=" "
				if tonumber(Warp[5])~=0 then
					 EventName=Warp[6]
				 end
			NLG.SystemMessage(-1,"[ƥ] ҡ"..tName.."."..tLevel.."ļ"..Ҫȼ.."϶ǰ"..ͼ.."Ҫ"...."/"..)
			NLG.SystemMessage(-1,"[ƥ] ǰҪ"..EventName)
		else
			NLG.SystemMessage(_PlayerIndex,"[ϵͳ]ħҲ500޷㲥")
		end
		return ;
	end
	if tonumber(_Seqno) ==888 and  tonumber(_Data)==2 then----------ϵͳ㲥
			if ƥ[CdKey]~=nil and  ʱͼ¼[CdKey]==nil and #ƥ[CdKey]>1 then
				for i=1,#ƥ[CdKey] do		----ɾ1-5
					NLG.ShowWindowTalked(ƥ[CdKey][i],_MeIndex, 0, 0,997,ȷƥ(_PlayerIndex).."\n򷢳 2  \nʮûȡ¼");
					NLG.SystemMessage(ƥ[CdKey][i],"[ƥ] ӳѾҪ󿪳ȷ 2 ")
					--ʱ¼		
				end
				PlayerTime[CdKey]=Num(os.time())
				ʱͼ¼[CdKey]={}
			else
				NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\nֻжӳܿ棡鲻С2");
			end
		return
	end
	if tonumber(_Seqno) ==PrtJiLu[_PlayerIndex] and  tonumber(_Data)<0 then
		local tselect =50
		if _Select == 16 then ---һť
			PrtJiLu[_PlayerIndex] = tonumber(PrtJiLu[_PlayerIndex])-1
			if PrtJiLu[_PlayerIndex]==0 then--һҳ
				tselect =34
			end
		elseif _Select == 32 then ---һť
			PrtJiLu[_PlayerIndex] =  tonumber(PrtJiLu[_PlayerIndex])+1
			if ʱ¼[_PlayerIndex]==1 then
				local Max_Seqno=math.floor(#Ŵ͵ͼ/6)
				if PrtJiLu[_PlayerIndex] >= Max_Seqno or PrtJiLu[_PlayerIndex]*6==#Ŵ͵ͼ then
					tselect =18
				end
			else
				local Max_Seqno=math.floor(#ƥ䴴/6)
				if PrtJiLu[_PlayerIndex] >= Max_Seqno or PrtJiLu[_PlayerIndex]*6==#ƥ䴴 then
					tselect =18
				end
			end
		end
		if ʱ¼[_PlayerIndex]==1 then
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, tselect, PrtJiLu[_PlayerIndex],鴰(_PlayerIndex,PrtJiLu[_PlayerIndex],Ŵ͵ͼ));
		else
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 2, tselect, PrtJiLu[_PlayerIndex],鿴鴰(_PlayerIndex,PrtJiLu[_PlayerIndex]));
		end
		return ;
	end
	------------------------------------------
	if ʱ¼[_PlayerIndex]==3 and tonumber(_Seqno) ==899 then
		local ToNumber= PrtJiLu[_PlayerIndex]
		local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
		local ͼ =Warp[1]
		local Ҫȼ = tonumber(Warp[2]);
		if tonumber(_Data)== nil  then
			_Data=Ҫȼ
		end	
		if tonumber(_Data)< Ҫȼ  or tonumber(_Data) >150 then
			_Data=Ҫȼ
		end	
		ʱ¼[_PlayerIndex] =tonumber(_Data)
		NLG.ShowWindowTalked(_PlayerIndex,
																				_MeIndex, 1, 3, 898, "\nǼǡ " ..
																				"\n" ..
																				"\nǰѡ㣺" ..ͼ..
																				"\n" ..
																				"\n" ..
																				"\n(Ϊ2ֵΪ5ĬΪ5)");
		return ;
	end
	if tonumber(_Seqno) ==898 then
		if tonumber(_Data)== nil  then
			_Data=5
		end	
		if tonumber(_Data)< 2  or tonumber(_Data) >5 then
			_Data=5
		end	
		local ToNumber= PrtJiLu[_PlayerIndex]
		local Ҫȼ= ʱ¼[_PlayerIndex]
		local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
		local ͼ =Warp[1]
		local շ = tonumber(Warp[3]);
		local EventName=" "
		if  tonumber(Warp[5])~=0 then
			 EventName=Warp[6]
		 end
		if жǼ(_PlayerIndex,ʱ¼[_PlayerIndex],ToNumber) == 0 then
     Char.AddGold(_PlayerIndex,-շ); 
		--local money = Char.GetData(_PlayerIndex,%_%);
			--Char.SetData(_PlayerIndex,%_%,money-շ);
			--NLG.UpChar(player);	
				---ʽ{ص,ȼ,,{ң..}}
				ƥ[CdKey]={_PlayerIndex}
				ƥ䴴[CdKey]={ToNumber,ʱ¼[_PlayerIndex],tonumber(_Data)}
				--table.insert(ƥ䴴, {ToNumber,ʱ¼[_PlayerIndex],tonumber(_Data),{_PlayerIndex}})
				ѵǼǵص[_PlayerIndex]=CdKey
				NLG.SystemMessage(-1,"[ƥʾ] ҡ"..tName.."."..tLevel.."ļ"..Ҫȼ.."϶ǰ"..ͼ.."ǰҪ"..EventName)
		end
		return ;
	end
	if _Seqno ~=999 and _Seqno < 100 and tonumber(_Data)>0 then --ƥ
		if ѵǼǵص[_PlayerIndex]~= nil then
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\nǰѾ¼Ǽǵ㣬µǼȡǼǵ㣡");
			return
		end	
		if ʱ¼[_PlayerIndex]==1 then
			local ToNumber=PrtJiLu[_PlayerIndex]*6+tonumber(_Data)
			local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
			local ͼ =Warp[1]
			local Ҫȼ = tonumber(Warp[2]);
			local շ = tonumber(Warp[3]);
			local Map = Split(Warp[4],",");
			local MapID =Map[2]
			local MapX =Map[3]
			local MapY =Map[4]
			local Event =tonumber(Warp[5])
			local EventName=Warp[6]
			NLG.ShowWindowTalked(_PlayerIndex,
																				  _MeIndex, 1, 3, 899, "\nǼǡ " ..
																				"\n" ..
																				"\nĿǰ㣺" ..ͼ..
																				"\n" ..
																				"\nȼ" ..
																				"\n(Ϊ"..Ҫȼ.."ֵΪ150)");
			ʱ¼[_PlayerIndex]=3
			 PrtJiLu[_PlayerIndex]=tonumber(ToNumber)
			return
		end	
		if ʱ¼[_PlayerIndex]==2 then
			if ѵǼǵص[_PlayerIndex]~=nil then
				NLG.SystemMessage(_PlayerIndex,"[ϵͳ]ǰѾǼǹƥ")
				return ;
			end
			local ToNumber=ƥб[_PlayerIndex][PrtJiLu[_PlayerIndex]*6+tonumber(_Data)]
			local Ǽǵص=ToNumber[2][1]
			local Warp = Split(Ŵ͵ͼ[Ǽǵص],"|");
			local ͼ =Warp[1]
			local Ҫȼ = tonumber(Warp[2]);
			local շ = tonumber(Warp[3]);
			local Level=ToNumber[2][2]
			local =ToNumber[2][3]
			local ӳCdKey=ToNumber[1]
			if жǼ(_PlayerIndex,Level,Ǽǵص) == 0 then
				if ʱͼ¼[ӳCdKey]~=nil then
					NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n ĿǰڴԺ򣡣");
					return
				end
				if  ==#ƥ[ӳCdKey] then
					NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n ĿǰڴԺ򣡣");
					return
				end
				ѵǼǵص[_PlayerIndex]=ӳCdKey
				Char.AddGold(_PlayerIndex,-շ); 
--		local money = Char.GetData(_PlayerIndex,%_%);
--			Char.SetData(_PlayerIndex,%_%,money-շ);
--			NLG.UpChar(player);	
				---ʽ{ص,ȼ,,{ң..}}
				table.insert(ƥ[ӳCdKey], _PlayerIndex)
			end
			if  ==#ƥ[ӳCdKey] then
				for i=1,#ƥ[ӳCdKey] do		----ɾ1-5
					NLG.ShowWindowTalked(ƥ[ӳCdKey][i],_MeIndex, 0, 0,997,ȷƥ(_PlayerIndex).."\n򷢳 2  \nʮûȡ¼");
					NLG.SystemMessage(ƥ[ӳCdKey][i],"[ƥ] ۻ".. .."ҡ"..tName.."."..tLevel.."ѾǼ"..Ҫȼ.."϶ǰ"..ͼ.."ȷ 2 ")
					--ʱ¼		
				end
				PlayerTime[ӳCdKey]=Num(os.time())
				ʱͼ¼[ӳCdKey]={}
			else
				for i=1,#ƥ[ӳCdKey] do
					NLG.SystemMessage(ƥ[ӳCdKey][i],"[ƥ] ҡ"..tName.."."..tLevel.."ѾǼǼǵ㣬ĿǰԱ"..#ƥ[ӳCdKey])
				end
			end
		end
	end
end
function жǼ(_PlayerIndex,Level,ToNumber)
		local _MeIndex=IntNpc["ƥNPC"]
		local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
		local ͼ =Warp[1]
		local Ҫȼ =Level
		local շ = tonumber(Warp[3]);
		local Map = Split(Warp[4],",");
		local MapID =Map[2]
		local MapX =Map[3]
		local MapY =Map[4]
		local Event =tonumber(Warp[5])
		local EventName=Warp[6]
		local tName= Char.GetData(_PlayerIndex,%_ԭ%)
		local tLevel= Char.GetData(_PlayerIndex,%_ȼ%)
		if  Event~=0 then 
			if Event> 0 then
				if Char.NowEvent(_PlayerIndex,Event) ~= 1 then
					NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n޷ʹ㣬"..EventName.."");
					--NLG.SystemMessage(_PlayerIndex,"[ϵͳ] ޿"..ͼ.."޷,ֱӴ͡");
					return -1
				end	
			else
				if Char.ItemNum(_PlayerIndex,Event*-1) < 1 then
					NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n޷ʹ㣬ӵеߣ"..EventName.."");
					--NLG.SystemMessage(_PlayerIndex,"[ϵͳ] ޿"..ͼ.."޷,ֱӴ͡");
					return -1
				end
			end	
		end
		if (Char.GetData(_PlayerIndex,%_%)<շ) then
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n  ϵħҲշ"..շ.."G");
			--NLG.SystemMessage(_PlayerIndex,"[ϵͳ] ħҲ޷ʹôص,շ"..շ)
			return -1
		elseif (Char.GetData(_PlayerIndex,%_ȼ%)<Level) then
			NLG.ShowWindowTalked(_PlayerIndex,_MeIndex, 0, 2, 0,"\n\n\n\n ĵȼ޷ʹôص㣬Ҫ"..Ҫȼ.."");
			--NLG.SystemMessage(_PlayerIndex,"[ϵͳ] ĵȼ޷ʹôص㣬Ҫ"..Ҫȼ.."")
			return -1
		end
		return 0
end
function 鴰(_PlayerIndex,_Seqno,Tabtpy)
		local Max_Seqno=getIntPart(#Tabtpy/6) --󴰿
		local Num=6
		if _Seqno == Max_Seqno then
			Num=#Tabtpy - Max_Seqno*6
		end

		local buf = "3\nѡص" ..
		"\n"..string.format("%12.12s","ص") .. string.format("%8.8s","ȼ") .. string.format("%8.8s","շ")..string.format("%8.8s","Ҫ").."\n"..
		"-------------------------------------------\n"
		for i = _Seqno*6+1,_Seqno*6+Num do
			local Warp = Split(Tabtpy[i],"|");
			local ͼ =Warp[1]
			local Ҫȼ = tonumber(Warp[2]);
			local շ = tonumber(Warp[3]);
			local Ҫ = Warp[6] or ""
			local ="%8.8s"
			if Ҫ ~= "" then
				="%15.15s"
			end
			local Map = Split(Warp[4],",");
			local MapID =Map[2]
			local MapX =Map[3]
			local MapY =Map[4]
			buf = buf .. string.format("%12.12s",ͼ) .. string.format("%8.8s",Ҫȼ) .. string.format("%8.8s",շ)..string.format(,Ҫ).."\n"
		end
	return buf
end
function 鿴鴰(_PlayerIndex,_Seqno)
		--ʽ{ص,ȼ,,{ң..}}
		local Max_Seqno=getIntPart(#ƥб[_PlayerIndex]/6) --󴰿
		local Num=6
		if _Seqno == Max_Seqno then
			Num=#ƥб[_PlayerIndex]- Max_Seqno*6
		end
		local buf = "3\nѡص" ..
		"\n".. string.format("%8.8s","ӳ")..string.format("%12.12s","ص") .. string.format("%8.8s","ȼ") .. string.format("%8.8s","շ")..string.format("%8.8s","").."\n"..
		"-------------------------------------------\n"
		for i = _Seqno*6+1,_Seqno*6+Num do
			local ص=ƥб[_PlayerIndex][i][2][1]
			local Warp = Split(Ŵ͵ͼ[ص],"|");
			local ͼ =Warp[1]
			local Ҫȼ = tonumber(ƥб[_PlayerIndex][i][2][2]);
			local շ = tonumber(Warp[3]);
			local Ǽ= 0
			if ƥ[ƥб[_PlayerIndex][i][1]]~=nil then
				Ǽ = #ƥ[ƥб[_PlayerIndex][i][1]]
			end
			if ƥб[_PlayerIndex]~=nil then	
				if Players[ƥб[_PlayerIndex][i][1]]~=nil then
				local ӳ=Char.GetData(Players[ƥб[_PlayerIndex][i][1]].Index,%_ԭ%)
				local =Ǽ.."/"..tonumber(ƥб[_PlayerIndex][i][2][3])
				buf = buf .. string.format("%8.8s",ӳ)..string.format("%12.12s",ͼ) .. string.format("%8.8s",Ҫȼ) .. string.format("%8.8s",շ)..string.format("%8.8s",).."\n"
				end
			end
		end
	return buf
end

Delegate.RegDelTalkEvent("ƥ");
function ƥ( _PlayerIndex, _msg, _color, _range, _size)
	local Name = Char.GetData(_PlayerIndex,%_ԭ%)	
--	TalkMsg = string.sub(_msg,3)
--	TalkMsg = string.gsub(TalkMsg,"]","")
	if  _msg=="/ƥ" or _msg=="/7" then	
	NLG.ShowWindowTalked(_PlayerIndex,IntNpc["ƥNPC"], 2, 2, 999,
			"5\nƥ" ..
			"\n" ..
			"\nӭʹ[ƥ]ϵͳϵͳ˵£" ..
			"\n1ҿѡص㣬" ..
			"\n2֪ᷢͨ" ..
			"\n   С" ..
			"\n   С" ..
			"\n   ѯѡ" ..
			"\n   ȡǼǡ" ..
			"\n");
	end
	if  string.sub(_msg,3)=="2" then	
		local ӳCdKey=ѵǼǵص[_PlayerIndex]
		if PlayerTime[ӳCdKey]~=nil then
			table.insert(ʱͼ¼[ӳCdKey],_PlayerIndex)
		--ȴȷ
			local Ҽ¼=ƥ䴴[ӳCdKey]
			local ͵ص=Ҽ¼[1]
			local =Ҽ¼[3]
			if #ʱͼ¼[ӳCdKey] == or #ʱͼ¼[ӳCdKey] == #ƥ[ӳCdKey] then
				for i=1,#ƥ[ӳCdKey] do
					TWarpPlayer(ƥ[ӳCdKey][i])

					NLG.SystemMessage(ƥ[ӳCdKey][i],"[ϵͳ]Ѵ¼ص㡣")
				end
				
				PlayerTime[ӳCdKey]=nil
				ʱͼ¼[ӳCdKey]=nil
				ƥ䴴[ӳCdKey]=nil
				ƥ[ӳCdKey]=nil
			else
				NLG.SystemMessage(_PlayerIndex,"[ϵͳ]ȷ,ȴȷ")
			end
		end
	end
	if  TalkMsg =="/ڴ" then
		PrtJiLu = {}		--ʱָ
		ƥ= {}
		ʱ¼ =  {}			--ʱָ
		ƥ䴴 = {}		--¼ƥбʽ{ص,ȼ,,{ң..}}
		PlayerTime ={}					----ҽ׼״̬ = 0Ǵ׼ >0ǵȴ״̬
		WarpPlayerNum=WarpPlayerNum or {}				--¼{ص=} >=5ʼ
		ƥб= {}
		ʱͼ¼={}
	end
end
function ȷƥ(_PlayerIndex)
		local  CdKey=ѵǼǵص[_PlayerIndex]
		local Ҽ¼=ƥ䴴[CdKey]
		---ʽ{ص,ȼ,}
		local Ŀǰƥ=ƥ[CdKey]
		local ToNumber=Ҽ¼[1]
		local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
		local WName =Warp[1]
		local Ҫȼ = tonumber(Warp[2]);
		local շ = tonumber(Warp[3]);
		local Map = Split(Warp[4],",");
		local MapID =Map[2]
		local MapX =Map[3]
		local MapY =Map[4]
		local Msg =" ƥ" ..
		"\\nǰǼǣ"..WName.."\\nҪǣ"..Ҽ¼[3]..
		"\\n".. string.format("%10.10s","") .. string.format("%15.15s","ְҵ")..string.format("%8.8s","ȼ").."\\n"
		for i=1,#Ŀǰƥ do	
			local tName= Char.GetData(Ŀǰƥ[i],%_ԭ%)
			local tJob=GetJobName(Char.GetData(Ŀǰƥ[i],%_ְID%))
			local tLevel= Char.GetData(Ŀǰƥ[i],%_ȼ%)
			Msg=Msg..string.format("%10.10s",tName) .. string.format("%15.15s",tJob)..string.format("%8.8s",tLevel).."\\n"
		end
	return Msg
end
function ȡƥ(_PlayerIndex)
		local  CdKey=ѵǼǵص[_PlayerIndex]
		local Ҽ¼=ƥ䴴[CdKey]
		---ʽ{ص,ȼ,}
		local Ŀǰƥ=ƥ[CdKey]
		local ToNumber=Ҽ¼[1]
		local Warp = Split(Ŵ͵ͼ[ToNumber],"|");
		local WName =Warp[1]
		local Ҫȼ = tonumber(Warp[2]);
		local շ = tonumber(Warp[3]);
		local Map = Split(Warp[4],",");
		local MapID =Map[2]
		local MapX =Map[3]
		local MapY =Map[4]
		local Num=3+tonumber(#Ŀǰƥ)
		local Msg =Num.."\\nƥ" ..
		"\\nǰǼ["..WName.."] Ҫ["..Ҽ¼[3].."]"..
		"\\n".. string.format("%14.14s","") .. string.format("%15.15s","ְҵ")..string.format("%8.8s","ȼ").."\\n"
		for i=1,#Ŀǰƥ do	
			local tName= Char.GetData(Ŀǰƥ[i],%_ԭ%)
			local tJob=GetJobName(Char.GetData(Ŀǰƥ[i],%_ְID%))
			local tLevel= Char.GetData(Ŀǰƥ[i],%_ȼ%)
			Msg=Msg..string.format("%14.14s",tName) .. string.format("%15.15s",tJob)..string.format("%8.8s",tLevel).."\\n"
		end
		Msg=Msg.."·㲥(500ħ/)".."\\nǿп֪ͨѿ"
	return Msg
end

function Warp_LoopEvent(_MeIndex) ----ѭ¼
	for k,v in pairs(PlayerTime) do
		if Num(os.time())-v>=30 then 
			local ӳCdKey=k
			local Ҽ¼=ƥ䴴[ӳCdKey]
			local =Ҽ¼[3]
			local Ŀǰƥ=#ƥ[ӳCdKey]
			local ͵ص=Ҽ¼[1]
			for i=1,#ƥ[ӳCdKey] do
				local жϼ¼=0
				for b=1,#ʱͼ¼[ӳCdKey] do
					if ѵǼǵص[ƥ[ӳCdKey][i]]~= nil then
						if ƥ[ӳCdKey][i]==ʱͼ¼[ӳCdKey][b] then
							NLG.SystemMessage(ƥ[ӳCdKey][i],"[ϵͳ]ĶѲʱҪɣȴұ")
							жϼ¼=1
							break
						end
					end
				end
				if жϼ¼==0 then
					if ѵǼǵص[ƥ[ӳCdKey][i]]~= nil then
						NLG.SystemMessage(ƥ[ӳCdKey][i],"[ϵͳ]ʱΪƥ񣬶Ҫ,ҪµǼǡ")
						DelWarpPlayer(ƥ[ӳCdKey][i])
					end
				end
			end
			ʱͼ¼[ӳCdKey]=nil
			PlayerTime[ӳCdKey]=nil
		end
	end
end

Delegate.RegDelLogoutEvent("WarpOutEvent"); --ǳ¼
function WarpOutEvent(_PlayerIndex)
	if ѵǼǵص[_PlayerIndex]~= nil then
		DelWarpPlayer(_PlayerIndex)
	end
end
function DelWarpPlayer(_PlayerIndex)---ҵ½Ϣ
	local ӳCdKey=ѵǼǵص[_PlayerIndex]
	ѵǼǵص[_PlayerIndex]=nil
	local CdKey = Char.GetData(_PlayerIndex,2002)
	local  = Char.GetData(_PlayerIndex,%_ԭ%)
	local ص=ƥ䴴[ӳCdKey][1]
	local Warp = Split(Ŵ͵ͼ[ص],"|");
	local շ = tonumber(Warp[3]);
	Char.AddGold(_PlayerIndex,շ*0.8); 
	if CdKey~=ӳCdKey then
		local Ҽ¼=ƥ䴴[ӳCdKey]
		---ʽ{ص,ȼ,}
		for k,v in pairs(ƥ[ӳCdKey]) do
			NLG.SystemMessage(v,"[ϵͳ]"...."ȡǼǣ뿪")
			if v==_PlayerIndex then
				table.remove(ƥ[ӳCdKey],k)
			end
		end
	else
		if #ƥ[CdKey] ==1 then
			ƥ[CdKey] =nil
			ƥ䴴[CdKey]=nil
			NLG.SystemMessage(_PlayerIndex,"[ϵͳ]ȡǼǳɹ")
			return ;
		end
		local ¼¼={}
		for k,v in pairs(ƥ[ӳCdKey]) do
			if v~=_PlayerIndex then
				table.insert(¼¼,v)
			end
		end
		local NewCdKey=Char.GetData(¼¼[1],2002	)
		NLG.SystemMessage(¼¼[1],"[ϵͳ]Ѿöӳ")
		ƥ[NewCdKey]=¼¼
		ƥ䴴[NewCdKey]={ƥ䴴[CdKey][1],ƥ䴴[CdKey][2],ƥ䴴[CdKey][3]}
		ƥ䴴[CdKey]=nil
		for k,v in pairs(ѵǼǵص) do
			if v==CdKey then
				ѵǼǵص[k]=NewCdKey
			end
		end
		NLG.SystemMessage(_PlayerIndex,"[ϵͳ]Ѿȡ¼ϢҶӳת")
	end		
end
function CWarpPlayer(_PlayerIndex)---㣬ֵǴͷ
	local ret =0
	if ѵǼǵص[_PlayerIndex]~=nil then
		DelWarpPlayer(_PlayerIndex)
		NLG.SystemMessage(_PlayerIndex,"[ϵͳ]Ǽͷ÷")
	else
		NLG.SystemMessage(_PlayerIndex,"[ϵͳ]Ǽʧ")
	end
	return ret
end
function TWarpPlayer(_PlayerIndex)---㣬
		local ӳCdKey=ѵǼǵص[_PlayerIndex]
		local CdKey = Char.GetData(_PlayerIndex,2002	)
		local  = Char.GetData(_PlayerIndex,%_ԭ%)
		local ص=ƥ䴴[ӳCdKey][1]
		local Warp = Split(Ŵ͵ͼ[ص],"|");
		local WName =Warp[1]
		local Ҫȼ = tonumber(Warp[2]);
		local շ = tonumber(Warp[3]);
		local Map = Split(Warp[4],",");
		local MapID =Map[2]
		local MapX =Map[3]
		local MapY =Map[4]
	----------------------------ͲҼ¼
		NLG.DischargeParty(_PlayerIndex)
		NLG.Warp(_PlayerIndex,0,MapID,MapX,MapY);
		if CdKey~=ӳCdKey then
			Char.JoinParty(_PlayerIndex,Players[ӳCdKey].Index)
		end
		ѵǼǵص[_PlayerIndex]=nil
	return
end

function GetJobName(_TypeNo)
	local JobTypeName = {}
	JobTypeName[1]=""
	JobTypeName[10]="ʿ"
	JobTypeName[20]="սʿ"
	JobTypeName[30]="ʿ"
	JobTypeName[40]=""
	JobTypeName[50]="ʿ"
	JobTypeName[60]="ʿ"
	JobTypeName[70]="ħʦ"
	JobTypeName[80]="ʦ"
	JobTypeName[90]="ʦ"
	JobTypeName[100]="ʦ"
	JobTypeName[110]="ѱʦ"
	JobTypeName[120]=""
	JobTypeName[130]="ʦ"
	JobTypeName[140]="ʿ"
	JobTypeName[150]=""
	JobTypeName[160]=""
	JobTypeName[200]=""
	JobTypeName[210]="ս"
	JobTypeName[220]="ǹְ"
	JobTypeName[230]="Զ"
	JobTypeName[240]="ְ"
	JobTypeName[250]="ְ"
	JobTypeName[260]="Сְ"
	JobTypeName[270]="װ"
	JobTypeName[280]="װ"
	JobTypeName[290]="ְ"
	JobTypeName[300]="ְ"
	JobTypeName[310]="ְ"
	JobTypeName[320]="ѥְ"
	JobTypeName[330]="Ьְ"
	JobTypeName[340]="ְ"
	JobTypeName[350]="ҩʦ"
	JobTypeName[360]="ҩʦ"
	JobTypeName[370]="ʦ"
	JobTypeName[380]="ʦ"
	JobTypeName[390]="ʦ"
	JobTypeName[400]="Ϥ"
	JobTypeName[410]="̽"
	JobTypeName[420]=""
	JobTypeName[430]="ʿ"
	JobTypeName[440]="ҽ"
	JobTypeName[450]="ɼ"
	JobTypeName[460]=""
	JobTypeName[470]=""
	JobTypeName[480]=""
	JobTypeName[1000]="ʦ"
	JobTypeName[1010]="֯"
	JobTypeName[170]="ʥʿ"
	JobTypeName[180]="Ӱ̿"
	JobTypeName[190]="ħʿ"
	JobTypeName[720]="װ"
	JobTypeName[710]="װ"
	JobTypeName[730]="װ"
	JobTypeName[740]="ȭ"
	if _TypeNo==0 then _TypeNo=1 end
	if JobTypeName[_TypeNo] == nil then
		JobTypeName[_TypeNo] = "δְ֪ҵ"
	end
	return JobTypeName[_TypeNo]
end



