ShowMessage("捎口信 $Rev: 206 $")

--[[
[author]
perday_max=1
]]--
script_name="捎口信"

local g_szMission = "捎口信"
local g_nIndex = -1
local g_idMission = 0
local g_idScript = 0

function OnMission()

	while true do
		g_nIndex, g_idMission, g_idScript = DataPool:GetPlayerMission(g_szMission)

		if g_nIndex ~= -1 then
			-- 接到任务
			--[[
			local nParam = {}
			for i=0,7 do
				nParam[i] = DataPool:GetPlayerMission_Variable(g_nIndex, i)
				DbgPrintf("[%d]%d", i, nParam[i])
			end
			]]--

			local idNPC = DataPool:GetPlayerMission_Variable(g_nIndex, 5)
			MissionMoveToNPC(tonumber(idNPC))
			QuestFrameOptionClicked(g_szMission, CMP_PART_MATCH)	-- 选择选项
			QuestFrameMissionComplete()	-- 完成
		else
			MoveToNPC(232, 319, 0, "邱行洛")
			QuestFrameOptionClicked(g_szMission, CMP_PART_MATCH)	-- 选择选项
			
			local strType,_,_,_,szText = DataPool:GetNPCEventList_Item(0);

			if strType == "text" then
				if string.find(szText, "10次口信") then
					ShowMessage("捎口信任务：已经完成10次！")
					System:UpdateRecord( script_name )
					break
				end
			end
		end
		
		System:Sleep(200)
	end
end

function _SMain(...)
	OnMission()
end

_SMain()