<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>

--[v1.0]--

--====== User Options ======--

	runtimelimit = nil	-- limits the script run in minutes. if set to nil, then the script runs non-stop.

--==========================--


player:update()
yrest(500)
loadProfile()
yrest(500)

EventMonitorStart("Sysmsg", "SYSTEM_MESSAGE")

function battle(arg)
	local battlebegins = getTEXT("BG_AA_PREPARE04")
	local battleisover = getTEXT("BG_AA_END")
	local time, _, msg = EventMonitorCheck("Sysmsg", "1")
	if (arg == "begins" and msg and msg:find(battlebegins)) or (arg == "isover" and msg and msg:find(battleisover)) then
		return true
	end
	return false
end

runtimelimit = tonumber(runtimelimit)
endscript = false
scriptstarttime = os.time()

repeat

	joinBG("aa", 60)

	yrest(2000)

	if inBG("aa") then
		repeat
			yrest(1000)
		until battle("isover")

		yrest(2000)

		leaveBG(30)
	end	

	local runtimemins = math.floor((os.time()-scriptstarttime)/60)
	if runtimelimit and runtimelimit >= runtimemins then endscript = true end

until endscript

EventMonitorStop("Sysmsg")

</onLoad>

</waypoints>