ShowMessage("Ͻս $Rev: 214 $")

--[[
[author]
class=3
descript="ÿܿϽ20"
]]--
perday_max=1
script_name="Ͻս"

function OnMission()

	while true do 
		
		System:Sleep(500)

		if CityToGuild() == false then
			ShowMessage("ûаɳУ")
			return
		end
			
		MoveToNPC( 101, 58,-1, "" )

		local nCount = DataPool:UserBag_CountItemByName("ս")
		if nCount < 1 then
			ShowMessage("ս㣬ű")
			return
		end	

		if nCount > 10 then
			QuestFrameOptionClicked("Ͻ10ս", CMP_PART_MATCH)
			ShowMessage("Ͻ10ս")
		elseif nCount > 5  then
			QuestFrameOptionClicked("Ͻ5ս", CMP_PART_MATCH)
			ShowMessage("Ͻ15ս")
		else
			QuestFrameOptionClicked("Ͻ1ս", CMP_PART_MATCH)
			ShowMessage("Ͻ1ս")
		end

		System:Sleep(1500)
		
		local isNext,szMsg = GetDebugMessage()
		while isNext == 1 do

			if string.find(szMsg, "㱾Ͻ20ս") then
				ShowMessage("Ѿ㹻ս񣬽ű")
				System:UpdateRecord( script_name )
				return
			elseif string.find(szMsg, "ûδս") then
				ShowMessage("ս㣬ű")
				System:UpdateRecord( script_name )
				return
			end

			isNext,szMsg = GetDebugMessage()
		end

		if UI:IsWindowShow("LoginSelectServerQuest") then
			DoLuaString("LoginSelectServerQuest_Env" , "SelectServerQuest_Bn2Click()")
			DoLuaString("LoginSelectServerQuest_Env" , "SelectServerQuest_Frame_OnHiden()")
			ShowMessage("Ѿ㹻ս񣬽ű")
			System:UpdateRecord( script_name )
			return
		end
	end

end

function _SMain(...)

	local nCount = DataPool:UserBag_CountItemByName("ս")
	if nCount <= 0 then
		ShowMessage("ûսִֹͣнű")
		return 
	end

	OnMission()

	GuildToCity(0)

end

_SMain()

