Jump to content

Recommended Posts

Posted

TvT event addons.

Config for Coliseum Doors Close

and Interval time.

 

Index: trunk/L2JTeon/java/config/Custom/L2JTeonMods.properties
===================================================================
--- /tmp/svn_fs20100723-29606-1862i5m-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-1iufh0i-0	Fri Jul 23 15:53:20 2010
@@ -52,6 +52,9 @@
# players with cursed weapon are allowed to join ?
TvtJoinWithCursedWeapon=True

+# we must close coliseum doors on tvt start up?
+TvTCloseColiseumDoors = False
+
# ------------------------------------------------------------- #
#                       CTF Event Engine                        #
# ------------------------------------------------------------- #

Index: trunk/L2JTeon/java/net/sf/l2j/Config.java
===================================================================
--- /tmp/svn_fs20100723-29606-1isqhr4-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-j6ert5-0	Fri Jul 23 15:53:20 2010
@@ -765,6 +765,7 @@
	public static boolean TVT_ANNOUNCE_TEAM_STATS;
	public static boolean TVT_PRICE_NO_KILLS;
	public static boolean TVT_JOIN_CURSED;
+	public static boolean TVT_CLOSE_COLISEUM_DOORS;
	// * CTF Event Engine *//
	public static String CTF_EVEN_TEAMS;
	public static boolean CTF_ALLOW_INTERFERENCE;
@@ -2479,6 +2480,7 @@
					TVT_ANNOUNCE_TEAM_STATS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtAnnounceTeamStats", "False"));
					TVT_PRICE_NO_KILLS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtPriceNoKills", "False"));
					TVT_JOIN_CURSED = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvtJoinWithCursedWeapon", "True"));
+					TVT_CLOSE_COLISEUM_DOORS = Boolean.parseBoolean(L2JTeonEventMods.getProperty("TvTCloseColiseumDoors", "False"));
					// -------------------- //
					// CTF Event Engine //
					// -------------------- //

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminTvTEngine.java
===================================================================
--- /tmp/svn_fs20100723-29606-zz246b-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-w17z1-0	Fri Jul 23 15:53:20 2010
@@ -29,11 +29,12 @@
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.entity.L2JTeonEvents.TvT;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.util.Util;

public class AdminTvTEngine implements IAdminCommandHandler
{
	private static final String[] ADMIN_COMMANDS = { "admin_tvt", "admin_tvt_name", "admin_tvt_desc", "admin_tvt_join_loc", "admin_tvt_minlvl", "admin_tvt_maxlvl", "admin_tvt_npc", "admin_tvt_npc_pos", "admin_tvt_reward", "admin_tvt_reward_amount", "admin_tvt_team_add", "admin_tvt_team_remove", "admin_tvt_team_pos", "admin_tvt_team_color", "admin_tvt_join", "admin_tvt_teleport",
-			"admin_tvt_start", "admin_tvt_abort", "admin_tvt_finish", "admin_tvt_sit", "admin_tvt_dump", "admin_tvt_save", "admin_tvt_load", "admin_tvt_jointime", "admin_tvt_eventtime", "admin_tvt_autoevent", "admin_tvt_minplayers", "admin_tvt_maxplayers" };
+			"admin_tvt_start", "admin_tvt_abort", "admin_tvt_finish", "admin_tvt_sit", "admin_tvt_dump", "admin_tvt_save", "admin_tvt_load", "admin_tvt_jointime", "admin_tvt_eventtime", "admin_tvt_autoevent", "admin_tvt_minplayers", "admin_tvt_maxplayers", "admin_tvt_interval" };
	private static final int REQUIRED_LEVEL = 100;

	public boolean useAdminCommand(String command, L2PcInstance activeChar)
@@ -197,6 +198,13 @@
		else if (command.equals("admin_tvt_dump")) {
			TvT.dumpData();
		}
+		else if (command.startsWith("admin_tvt_interval "))
+		{
+			int value = Integer.valueOf(command.substring(19));
+
+			TvT._intervalBetweenMatchs = Util.convertMinutesToMiliseconds(value);
+			showMainPage(activeChar);
+		}
		return true;
	}

@@ -247,7 +255,10 @@
		replyMSG.append("<td width=\"100\"><button value=\"Join\" action=\"bypass -h admin_tvt_join\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Teleport\" action=\"bypass -h admin_tvt_teleport\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Start\" action=\"bypass -h admin_tvt_start\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
+		//L2EMU_ADD
		replyMSG.append("</tr></table><table><tr>");
+		replyMSG.append("<td width=\"100\"><button value=\"Set Interval\" action=\"bypass -h admin_tvt_interval $input1\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
+		replyMSG.append("</tr></table><table><tr>");
		replyMSG.append("<td width=\"100\"><button value=\"Abort\" action=\"bypass -h admin_tvt_abort\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("<td width=\"100\"><button value=\"Finish\" action=\"bypass -h admin_tvt_finish\" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td>");
		replyMSG.append("</tr></table><br><table><tr>");

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/model/entity/L2JTeonEvents/TvT.java
===================================================================
--- /tmp/svn_fs20100723-29606-eaztck-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-gzh6l5-0	Fri Jul 23 15:53:20 2010
@@ -32,6 +32,7 @@
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.ThreadPoolManager;
+import net.sf.l2j.gameserver.datatables.DoorTable;
import net.sf.l2j.gameserver.datatables.NpcTable;
import net.sf.l2j.gameserver.datatables.SpawnTable;
import net.sf.l2j.gameserver.lib.Rnd;
@@ -446,6 +447,11 @@

	public static void startEvent(L2PcInstance activeChar)
	{
+		if (_inProgress)
+		{
+			activeChar.sendMessage("A TvT event is already in progress, try abort.");
+			return;
+		}
		if (!startEventOk())
		{
			if (_log.isDebugEnabled()) {
@@ -455,8 +461,13 @@
		}
		_teleport = false;
		sit();
+		
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			closeColiseumDoors();
+
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Started. Go to kill your enemies!");
		_started = true;
+		_inProgress = true;
	}

	public static void setJoinTime(int time)
@@ -480,34 +491,64 @@
		}
		_teleport = false;
		sit();
+		
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			closeColiseumDoors();
+		
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Started. Go to kill your enemies!");
		_started = true;
		return true;
	}

-	public static void autoEvent()
+	public static synchronized void autoEvent()
	{
+		_log.info("Starting TvT!");
+		_log.info("Matchs Are Restarted At Every: " + getIntervalBetweenMatchs() + " Minutes.");
		if (startAutoJoin())
		{
-			if (_joinTime > 0) {
+			_eventType = 2;
+
+			if (_joinTime > 0)
				waiter(_joinTime * 60 * 1000); // minutes for join event
-			} else if (_joinTime <= 0)
+			else if (_joinTime <= 0)
			{
+				_log.info("TvT: join time <=0 aborting event.");
				abortEvent();
				return;
			}
			if (teleportAutoStart())
			{
-				waiter(1 * 60 * 1000); // 1 min wait time untill start fight after teleported
+				waiter(30 * 1000); // 30 sec wait time untill start fight after teleported
				if (startAutoEvent())
				{
+					_log.debug("TvT: waiting.....minutes for event time " + TvT._eventTime);
+
					waiter(_eventTime * 60 * 1000); // minutes for event time
					finishEvent();
+
+					_log.info("TvT: waiting... delay for final messages ");
+					waiter(60000);//just a give a delay delay for final messages
+					sendFinalMessages();
+
+					if (_finished && _eventType == 2)
+						_log.info("TVT: waiting.....delay for restart event  " + TvT.getIntervalBetweenMatchs() + " minutes.");
+					waiter(60000);//just a give a delay to next restart
+
+					try
+					{
+						restartEvent();
+					}
+					catch (Exception e)
+					{
+						_log.error("Error while tying to Restart Event", e);
+						e.printStackTrace();
+					}
				}
			}
			else if (!teleportAutoStart())
			{
				abortEvent();
+				restartEvent();
			}
		}
	}
@@ -705,9 +746,13 @@

	private static boolean finishEventOk()
	{
-		if (!_started) {
+		if (!_started)
			return false;
-		}
+
+		_inProgress = false;
+		if (Config.TVT_CLOSE_COLISEUM_DOORS)
+			openColiseumDoors();
+
		return true;
	}

@@ -760,6 +805,7 @@
		_joining = false;
		_teleport = false;
		_started = false;
+		_inProgress = false;
		unspawnEventNpc();
		Announcements.getInstance().announceToAll(_eventName + "(TvT): Match aborted!");
		teleportFinish();
@@ -904,6 +950,7 @@
		_eventTime = 0;
		_minPlayers = 0;
		_maxPlayers = 0;
+		_intervalBetweenMatchs = 0;
		java.sql.Connection con = null;
		try
		{
@@ -932,6 +979,7 @@
				_eventTime = rs.getInt("eventTime");
				_minPlayers = rs.getInt("minPlayers");
				_maxPlayers = rs.getInt("maxPlayers");
+				_intervalBetweenMatchs = rs.getLong("delayForNextEvent");
			}
			statement.close();
			int index = -1;
@@ -987,7 +1035,7 @@
			statement = con.prepareStatement("Delete from tvt");
			statement.execute();
			statement.close();
-			statement = con.prepareStatement("INSERT INTO tvt (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+			statement = con.prepareStatement("INSERT INTO tvt (eventName, eventDesc, joiningLocation, minlvl, maxlvl, npcId, npcX, npcY, npcZ, npcHeading, rewardId, rewardAmount, teamsCount, joinTime, eventTime, minPlayers, maxPlayers, delayForNextEvent) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
			statement.setString(1, _eventName);
			statement.setString(2, _eventDesc);
			statement.setString(3, _joiningLocationName);
@@ -1005,6 +1053,7 @@
			statement.setInt(15, _eventTime);
			statement.setInt(16, _minPlayers);
			statement.setInt(17, _maxPlayers);
+			statement.setLong(18, _intervalBetweenMatchs);
			statement.execute();
			statement.close();
			statement = con.prepareStatement("Delete from tvt_teams");
@@ -1441,4 +1490,134 @@
		}
		_teamPlayersCount.set(index, teamPlayersCount);
	}
+	public static long _intervalBetweenMatchs = 0;
+
+	/**
+	 * The type of TvT Event
+	 * 1 = Manual
+	 * 2 = Automatic
+	 */
+	public static int _eventType = 0;
+
+	private static boolean _inProgress = false;
+	private static boolean _finished = false;
+	private static boolean _aborted	= false;
+
+	/**
+	 * Opens All Coliseum Doors
+	 */
+	private static void closeColiseumDoors()
+	{
+		Announcements.getInstance().announceToAll("Closing Coliseum Doors, TvT event has just started !");
+		DoorTable.getInstance().getDoor(24190001).closeMe();//west gate out
+		DoorTable.getInstance().getDoor(24190002).closeMe();//west gate in
+		DoorTable.getInstance().getDoor(24190003).closeMe();//east gate out
+		DoorTable.getInstance().getDoor(24190004).closeMe();//east gate in
+
+		try
+		{
+			//just to give a lil delay :P
+			Thread.sleep(20);
+		}
+		catch (InterruptedException ie)
+		{
+			_log.fatal("Error, " + ie.getMessage());
+		}
+	}
+
+	/**
+	 * Open all Coliseum Doors
+	 */
+	private static void openColiseumDoors()
+	{
+		Announcements.getInstance().announceToAll("Opening Coliseum Doors, TvT event has finished!");
+		DoorTable.getInstance().getDoor(24190001).openMe();
+		DoorTable.getInstance().getDoor(24190002).openMe();
+		DoorTable.getInstance().getDoor(24190003).openMe();
+		DoorTable.getInstance().getDoor(24190004).openMe();
+
+	}
+
+	/**
+	 * Restarts Event
+	 * checks if event was aborted. and if true cancels restart task
+	 */
+	public synchronized static void restartEvent()
+	{
+		if (_aborted)
+		{
+			_log.debug("TvT: restart skipped, event was aborted.");
+			return;
+		}
+		_log.info("TvT: Event has been restarted...");
+		_joining = false;
+		_started = false;
+		_finished = false;
+		_inProgress = false;
+		long delay = _intervalBetweenMatchs;
+
+		Announcements.getInstance().announceToAll("TvT: joining period will be avaible again in " + getIntervalBetweenMatchs() + " minute(s)!");
+
+		waiter(delay);
+
+		try
+		{
+			autoEvent(); //start a new event
+		}
+		catch (Exception e)
+		{
+			_log.fatal("TvT: Error While Trying to restart Event...", e);
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Returns the event type by name.
+	 * @param value
+	 * @return
+	 */
+	public static String getEventTypeByName(int value)
+	{
+		String type = String.valueOf(value);
+
+		switch (value)
+		{
+		case 0:
+			type = ("None");
+			break;
+
+		case 1:
+			type = ("Manual");
+			break;
+
+		case 2:
+			type = ("Automatic");
+			break;
+		}
+		return type;
+	}
+
+	/**
+	 * just an announcer to send termination messages
+	 *
+	 */
+	public static void sendFinalMessages()
+	{
+		if (_finished && !_aborted)
+			Announcements.getInstance().announceToAll("TvT: Thank you For Participating At, " + "TVT Event.");
+	}
+
+	/**
+	 * returns the interval between each event
+	 * @return
+	 */
+	public static int getIntervalBetweenMatchs()
+	{
+		long actualTime = System.currentTimeMillis();
+		long totalTime = actualTime + _intervalBetweenMatchs;
+		long interval = totalTime - actualTime;
+		int seconds = (int) (interval / 1000);
+
+		return Math.round(seconds / 60);
+	}
}
\ No newline at end of file

Index: trunk/L2JTeon/java/net/sf/l2j/gameserver/util/Util.java
===================================================================
--- /tmp/svn_fs20100723-29606-14uvgwl-0	Fri Jul 23 15:53:20 2010
+++ /tmp/svn_fs20100723-29606-i9bjve-0	Fri Jul 23 15:53:20 2010
@@ -369,4 +369,8 @@
	{
		return calcCameraAngle(target.getHeading());
	}
+	public static int convertMinutesToMiliseconds(int minutesToConvert)
+	{
+		return minutesToConvert * 60000;
+	}
}

 

Credits to L2jTeon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • So few things for this guy:   He asked me to implement a code like EXP, SP, DROP runes in his server that did not work and he paid 27 Euro via Revolut.  He has no idea what compile, source is and he work with ubuntu.  I entered to his PC and using eclipse i add the code and compile as usually, i ask him to replace the jar with the new jar. He did not know how so i did it my self. Later on the ubuntu which im not familiar with could not continue and did not throw any error. I did not know what was happening until i asked Nightwolf who is experienced with Ubuntu and told me probably some error and can't continue. I was surprized since i only added few lines not edit or changed anything so i knew that the Login, Gameserver from source had mismatch with the compiled one. Later on i fix an error he had in raidboss_spawnlist where Long value tried to store inside Int value and explained him:   https://postimg.cc/F1zxMfDW   later on i explained him that source and compiled that he had had many issues and it was not my problem and he said that my code destroyed all his compiled.    In this point i ask @flatronnto post source or compile with my code inside to check the code i made and how he claim it destroyed his source. If he post then all can see what i added and it did not affect the source in an way other than edit the addExperience method - drop method and L2ItemInstance class. If he deny then all his trash talk is fake.   Then i tried contact him to resolve the issue even tho is not my problem, he paid for the code, i did the code, i was done but he ignored me:   https://postimg.cc/ts4RkjXt   I stopped after he claimed i destroyed intentionally his server, that i enter to other's PC to hack / destroy their compiles and when he said he will false advertise my server.    If @Nightw0lf can post he can also verify this guy is mentally ill not only he don't know compile, server, source, java differences but he also claim fake things that any other person with much money and good knowledge and patience could sue him online. He can't even open a proper report topic, he post in L2 OFF section.    In addition this guy offenses rudeness and treats is on another level, we had appointment at 18:00 GR time i was waiting for him 25 min and then i left PC for a bit, he showed up after 30 minutes and he said you're not here ill false advertisent you e.t.c.    https://postimg.cc/pmKNKcjV   He is mentally unstable and nobody should trade with this person. @Celestine Anyone can request LOG from my discord to see all conversation if he want. I have nothing to hide i worked for the money he paid and i did my job perfectly. I have 4-5 clients a week in last year and nobody had issues. Read the answer i just posted and you see who is right and who is wrong.
    • dsgl2 Pm me on discord i will try to help you to talk with winter , but again deal only with him or they will scam you 
    • I have what you're looking for already made, if you want, contact me. Greetings.
    • What webhosting are you using? You'll need to talk with administrators of the webhosting to open outgoing connections to port 1433, maybe they won't open it for you, instead, you should get a webhosting for mu online since they always have 1433 port open for outgoing connections. Also, make sure you have your 1433 TCP port open for incoming connections, for security, I suggest you exclusively add the cPanel IP Address to connect to your port 1433 in your firewall, so no one else can try to connect to your database. Let me know if you have any questions, happy to help.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock