szVulanLib = system.GetScriptFolder().."\\LIB\\VulanLib.lua"
IncludeFile(szVulanLib)
---------------------------------------------------------------------------------------
--Khai bao cac bien toan cuc
nHBRequest = 0 -- So luong HB can lay, neu = 0 se lay den khi het
---------------------------------------------------------------------------------------
LayHongBao = function()
	player.PathMoveTo(0, 0, "Tæng qu¶n LÔ phÈm ph­êng")
	timer.Sleep(1000)
	while player.GetDoingStatus() ~= 1 do timer.Sleep(100) end	

	if nHBRequest > 0 then
		for i = 1, nHBRequest do
			tbVulanLib.TalkToNpc("Tæng qu¶n LÔ phÈm ph­êng", 1)
			menu.ClickIndex(1, 0)
			tbVulanLib.WaitMenu(1);	
			if tbVulanLib.IsMenuTitle(1,"Tæng qu¶n LÔ phÈm ph­êng: ThËt ®¸ng tiÕc") ~= 0 then
				menu.Close()
				system.Print("<color=yellow>§· hÕt Hång Bao!")
				return
			end
			menu.ClickIndex(1, 0)
			timer.Sleep(10)
		end

	else
		while true do
			tbVulanLib.TalkToNpc("Tæng qu¶n LÔ phÈm ph­êng", 1)
			menu.ClickIndex(1, 0)
			tbVulanLib.WaitMenu(1);	
			if tbVulanLib.IsMenuTitle(1,"Tæng qu¶n LÔ phÈm ph­êng: ThËt ®¸ng tiÕc") == true then
				system.Print(menu.GetTitle())
				menu.Close()
				system.Print("<color=yellow>§· hÕt Hång Bao!")
				return
			end
			menu.ClickIndex(1, 0)
			timer.Sleep(10)
		end
	end
end
---------------------------------------------------------------------------------------
function main()
	LayHongBao()
	system.Print("<color=yellow>LÊy Hång Bao: Hoµn thµnh!")
end
---------------------------------------------------------------------------------------
