<waypoints type="RUN"><!-- AutoMailSender v0.3 by Bot_romka -->

	<onLoad>
		repeat zoneid = RoMScript("GetZoneID()") until zoneid
		repeat cur_gold = RoMScript("GetPlayerMoney('copper')") yrest(100) until cur_gold
		if zoneid ~= 19 then
			error("\a\a\You are too far from Land of Malevolence.")
		elseif distance(player.X,player.Z,-3170,48890) > 70	then
			error("\a\a\You are too far from Mailbox.")
		elseif(9 > inventory:itemTotalCount(227502)) then
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Not enough Excellent Belt. Buy Excellent Belt and Start again.|r')")
			error("\a\a\Error. Not enough Excellent Belt. Buy Excellent Belt and Start again.");
		elseif 528000 > cur_gold then
			error("\a\a\Error. GOLD WARNING!");
		elseif(24 > inventory:itemTotalCount(203276)) then		-- Amount of Experience Orb
			error("\a\a\Error. Not enough Experience Orb.");
		end
		
		EventMonitorStart("Recipient", "CHAT_MSG_WHISPER");
		function recipient()
			local recipient = "";
			RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Recipient checker started..|r')")
			repeat
				local time, moreToCome, name, msg = EventMonitorCheck("Recipient", "4,1")
				if time ~= nil then
					if( bot.ClientLanguage == "RU" ) then
						msg = utf82oem_russian(msg);
					end
					cprintf(cli.lightred, "Time: " ..os.date().. " Char name: " ..name.. " Message: " ..msg.. "\n")
					if string.find(msg,"Send me All.Pass:Z1d4r3a") or string.find(msg,"ShliMneVse") then
						recipient = name
						RoMScript("DEFAULT_CHAT_FRAME:AddMessage('|cffffff00Tirodel:Recipient Checked: " ..recipient.. ".|r')")
						break
					end
				end
			until false
		end
	</onLoad>

	<waypoint x="-3203" z="48882" y="176" tag="Mailbox">
		-- Check recipient
		printf("Recipient checker started.");
		recipient();
		-- Open Mailbox
		repeat npcname=RoMScript("TEXT('Sys110694_name')"); yrest(100) until npcname
		player:target_NPC(npcname,1500);					--- Почтовый ящик
		RoMScript("ChoiceOption(1);"); yrest(1500);
		-- Selecting and Send Item
		UMM_SendByNameOrId (recipient, 227502, 9);			--- Превосходный пояс
		UMM_SendByNameOrId (recipient, 203276, 1);			--- Шар опыта: 10 000 очков
		UMM_SendMoney (recipient, 20000);
		RoMScript("CloseWindows()"); yrest(100);
		-- Send ChatMessage to recipient
		RoMScript('SendChatMessage("All Ok.Pass:Z1d4r3a", "WHISPER", 0, " ..recipient.. ");');
		
		repeat cur_gold = RoMScript("GetPlayerMoney('copper')") yrest(100) until cur_gold
		cprintf(cli.white, "Gold:                  %s\n", cur_gold)
		cprintf(cli.white, "Excellent Belt:         %s\n", inventory:itemTotalCount(227502))
		cprintf(cli.white, "Experience Orb:         %s\n", inventory:itemTotalCount(203276))
		
		if(inventory:itemTotalCount(227502) >= 9) then
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Mailbox"));
		end
		
		if 18000 > cur_gold then
			error("\a\a\a\Error. GOLD WARNING!");
		elseif(1 > inventory:itemTotalCount(203276)) then		-- Amount of Experience Orb
			error("\a\a\a\Error. Not enough Experience Orb.");	
		end
	</waypoint>
	<waypoint x="-3164" z="48891" y="175" tag="Go2"></waypoint>
	<waypoint x="-3138" z="48903" y="173" tag="Store">
		-- Check Bag and amount of Excellent Belt
		inventory:update();
		if(1 > inventory:itemTotalCount(0) ) and not (inventory:itemTotalCount(227502) >= 9) then
			error("\a\a\Error. Not enough BagSpase. Clean Bag and Start again.");
		end
		-- Buy Excellent Belt
		n = inventory:itemTotalCount(0)
		repeat npcname=RoMScript("TEXT('Sys117108_name')"); yrest(100) until npcname
		repeat beltname=RoMScript("TEXT('Sys227502_name')"); yrest(100) until beltname
		player:openStore(npcname); yrest(1000);		--- Фред Дринкс
		inventory:storeBuyItem(beltname, n);		--- Превосходный пояс
		RoMScript("CloseWindows()");
		repeat cur_gold = RoMScript("GetPlayerMoney('copper')") yrest(100) until cur_gold
		cprintf(cli.white, "Gold:                  %s\n", cur_gold)
	</waypoint>
	<waypoint x="-3164" z="48891" y="175">__WPL:setWaypointIndex(__WPL:findWaypointTag("Mailbox"));</waypoint>
</waypoints>