Jump to content

Recommended Posts

Posted

New Away + Back Command System. Is really simple and nice.

 

How it works:

Version 1: When you type .away: You get a Green title " *Away * ", this commands also informs the players that you are away ( See in the Screenshots below ), also it costs 500Milion.

 

Version 2: Added Some useful protections. Changed Announcements text + Message to player.

 

Version 1: When you type .back: Away title is removed, also this command " .back " informs the players that you are back ( See in the Screenshots below ), .back is free.

 

Version 2: Added Some useful protections. Changed Announcements text + Message to player.

 

Screenshots:

Note: Screen is from Version 1, there have been some typos in Announcements and and. in Ver 2.

jfup2e.png

 

Patch:

Version 2.

### Eclipse Workspace Patch 1.0
#P L2JEclipse-Private
Index: trunk/Eclipse-Game/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/away.java
===================================================================
--- trunk/Eclipse-Game/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/away.java	(revision 0)
+++ trunk/Eclipse-Game/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/away.java	(revision 0)
@@ -0,0 +1,114 @@
+package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
+
+import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
+import net.sf.l2j.gameserver.Announcements;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+
+public class away implements IVoicedCommandHandler
+{
+    private static final String[] VOICED_COMMANDS = { "away", "back" };
+
+    public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+    {
+        if (command.equalsIgnoreCase("away"))
+        {
+            else if(activeChar.isInJail())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in Jail!");
+                return false;
+            }
+            else if(activeChar.isInOlympiadMode())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in the Olympiad now.");
+                return false;
+            }
+            else if(activeChar.atEvent)
+            {
+                activeChar.sendMessage("You cannot use this command while you are in an event.");
+                return false;
+            }
+            else  if (activeChar.isInDuel())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in a duel!");
+                return false;
+            }
+            else if (activeChar.inObserverMode())
+            {
+               activeChar.sendMessage("You cannot use this command while you are in Observer Mode.");
+            }
+            else if (activeChar.isFestivalParticipant())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in a festival.");
+                return false;
+            }
+            else if (activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in the dimensional rift.");
+                return false;
+            }
+            
+        	if(activeChar.getInventory().getItemByItemId(57) != null && activeChar.getInventory().getItemByItemId(57).getCount() >= 500000000)
+            {
+            activeChar.getInventory().destroyItemByItemId("Away", 57, 500000000, activeChar, activeChar.getTarget());
+			Announcements.getInstance().announceToAll("AWAY: " + activeChar + " is away");
+            activeChar.sendMessage("You are away from keyboard, 500Milion adena dissapeared, players informed.");
+            activeChar.getAppearance().setTitleColor(0xFF000);
+            activeChar.setTitle("*Away*"); // Title text when somebody is away.
+            activeChar.broadcastUserInfo();
+            }
+        }
+    
+        else
+        	
+        if (command.equalsIgnoreCase("back"))
+        {
+            else if(activeChar.isInJail())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in Jail!");
+                return false;
+            }
+            else if(activeChar.isInOlympiadMode())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in the Olympiad now.");
+                return false;
+            }
+            else if(activeChar.atEvent)
+            {
+                activeChar.sendMessage("You cannot use this command while you are in an event.");
+                return false;
+            }
+            else  if (activeChar.isInDuel())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in a duel!");
+                return false;
+            }
+            else if (activeChar.inObserverMode())
+            {
+               activeChar.sendMessage("You cannot use this command while you are in Observer Mode.");
+            }
+            else if (activeChar.isFestivalParticipant())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in a festival.");
+                return false;
+            }
+            else if (activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
+            {
+                activeChar.sendMessage("You cannot use this command while you are in the dimensional rift.");
+                return false;
+            }
+            
+            Announcements.getInstance().announceToAll("BACK: " + activeChar + " is back.");
+            activeChar.sendMessage("You are back. Players informed.");
+            activeChar.setTitle(" ");
+            activeChar.broadcastUserInfo();
+        }
+        return true;
+         		
+    }
+    
+    public String[] getVoicedCommandList()
+    {
+        return VOICED_COMMANDS;
+    }
+
+}
\ No newline at end of file
Index: trunk/Eclipse-Game/java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- trunk/Eclipse-Game/java/net/sf/l2j/gameserver/GameServer.java	(revision 223)
+++ trunk/Eclipse-Game/java/net/sf/l2j/gameserver/GameServer.java	(working copy)
@@ -199,6 +199,7 @@
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.TvT;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.trade;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.pm;
+import net.sf.l2j.gameserver.handler.voicedcommandhandlers.away;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Info;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Cl;
import net.sf.l2j.gameserver.handler.voicedcommandhandlers.karma;
@@ -616,6 +617,7 @@
       
       _voicedCommandHandler.registerVoicedCommandHandler(new karma());

+       _voicedCommandHandler.registerVoicedCommandHandler(new away());
                
		_log.config("VoicedCommandHandler: Loaded " + _voicedCommandHandler.size() + " handlers.");

 

Credits: ehh me.

Posted

Yes and then the server will have 294248928492849 announcements in a minute,you could do it without announcements.

Totally useless.

anyway gj.

You ***, read the code first. ~! AND BTW. Announcements is one Line. You can delete them !. Although theres something you can  do, you can use one item for this command that is rare, only " PROS " can use it.

Posted

Nice share . But BS® say is a bit true. If you have a server whit lot of people on you will have 2323232 announcements.But i think this no is a problem because if you have 300 players online . not all go on away mode.

Anyway nice share.

Posted

Nice share . But BS® say is a bit true. If you have a server whit lot of people on you will have 2323232 announcements.But i think this no is a problem because if you have 300 players online . not all go on away mode.

Anyway nice share.

as i said before, if you use for this command a rare item. One server with 300 Players online will have 1-2 Announcements per minute.

Posted

You nab, read the code first. ~!

 

You can't flame him w/o reason.

What he tells is true.

You haven't added even 1 simple protection, for example "Away can't be used out of peace zone" or "Players can't hit other players that are away" etc.

So, it's exploitable from many sides.

 

Not to mention that credits do not go to you.

Give more than half of credits to the real away author.

Posted

You can't flame him w/o reason.

What he tells is true.

You haven't added even 1 simple protection, for example "Away can't be used out of peace zone" or "Players can't hit other players that are away" etc.

So, it's exploitable from many sides.

 

Not to mention that credits do not go to you.

Give more than half of credits to the real away author.

I think this is the first time i can PROVE YOU Wrong. The author made many modifications in L2Attackble etc. I Haven't stole a line from his code. I made everything by my self. I was thinking what to add and then i was seaching the code from other Java files.. And Bum.

 

And i think is Kinda useful ! Players can farm and apart from custom armors etc. They can buy the item this command wants.

Posted

I think this is the first time i can PROVE YOU Wrong. The author made many modifications in L2Attackble etc. I Haven't stole a line from his code. I made everything by my self. I was thinking what to add and then i was seaching the code from other Java files.. And Bum.

 

Still, you can't prove me wrong on the fact that this is exploitable.

Posted

Still, you can't prove me wrong on the fact that this is exploitable.

Updated * With some protections.

 

 

"Players can't hit other players that are away" etc.

to make this i have to modify L2Attackable, like the real Away system. This is something else ^^. You just informing the players that you are away, and if someone haven't seen the announcement then he can see obviously a different color Title with text *Away*.

 

 

btw, i can show you many shares " Commands " That they don't have protections at all, and they need them ! So why you don't go and say the others to do the same. This thing shows that you have something with me ??... I don't have but you..

Posted

Here is the First away system.

Index: config/altsettings.properties
===================================================================
--- config/altsettings.properties	(revision 4757)
+++ config/altsettings.properties	(working copy)
@@ -520,3 +520,20 @@
# -------------------------------------------------------------
# Allow usage of mana potions
AllowManaPotions = False
+
+# -------------------------------------------------------------
+# Away System Config
+# -------------------------------------------------------------
+# Allow Players to change status Away
+AllowAwayStatus = True
+AwayOnlyInPeaceZone = True
+#Allow other Player target Away Player's
+AwayAllowInterference = False
+# Player take mobs aggro if he is Away
+AwayPlayerTakeAggro = False
+# Away status title Color (red 0000FF)
+AwayTitleColor = 0000FF
+# how many sec till player goes in away mode
+AwayTimer = 30
+# how many sec till player goes back from away mode
+BackTimer = 30
\ No newline at end of file
Index: src/main/java/com/l2jfree/Config.java
===================================================================
--- src/main/java/com/l2jfree/Config.java	(revision 4757)
+++ src/main/java/com/l2jfree/Config.java	(working copy)
@@ -1449,6 +1449,13 @@
	public static boolean				ALT_ITEM_SKILLS_NOT_INFLUENCED;
	public static boolean				ALT_MANA_POTIONS;
	public static int					ALT_AUTOCHAT_DELAY;
+	public static boolean				ALT_ALLOW_AWAY_STATUS;
+	public static int					ALT_AWAY_TIMER;
+	public static int					ALT_BACK_TIMER;
+	public static int					ALT_AWAY_TITLE_COLOR;
+	public static boolean				ALT_AWAY_ALLOW_INTERFERENCE;
+	public static boolean				ALT_AWAY_PLAYER_TAKE_AGGRO;
+	public static boolean				ALT_AWAY_PEACE_ZONE;

	// *******************************************************************************************
	// *******************************************************************************************
@@ -1662,6 +1669,13 @@

			ALT_MANA_POTIONS = Boolean.parseBoolean(altSettings.getProperty("AllowManaPotions", "false"));
			ALT_AUTOCHAT_DELAY = Integer.parseInt(altSettings.getProperty("AutoChatDelay", "30000"));
+			ALT_ALLOW_AWAY_STATUS = Boolean.parseBoolean(altSettings.getProperty("AllowAwayStatus", "False"));
+			ALT_AWAY_ALLOW_INTERFERENCE = Boolean.parseBoolean(altSettings.getProperty("AwayAllowInterference", "False"));
+			ALT_AWAY_PLAYER_TAKE_AGGRO = Boolean.parseBoolean(altSettings.getProperty("AwayPlayerTakeAggro", "False"));
+			ALT_AWAY_TITLE_COLOR = Integer.decode("0x" + altSettings.getProperty("AwayTitleColor", "0000FF"));
+			ALT_AWAY_TIMER = Integer.parseInt(altSettings.getProperty("AwayTimer", "30"));
+			ALT_BACK_TIMER = Integer.parseInt(altSettings.getProperty("BackTimer", "30"));
+			ALT_AWAY_PEACE_ZONE = Boolean.parseBoolean(altSettings.getProperty("AwayOnlyInPeaceZone", "False"));
		}
		catch (Exception e)
		{
Index: src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/ai/L2AttackableAI.java	(working copy)
@@ -200,10 +200,12 @@
			//event playere are also ignored
			if(player.isInFunEvent())
				return false;
-				
			// check if the target is within the grace period for JUST getting up from fake death
			if (player.isRecentFakeDeath())
				return false;
+			// check player is in away mod
+			if(player.isAway() && !Config.ALT_AWAY_PLAYER_TAKE_AGGRO)
+				return false;
		}
		// Check if the target is a L2Summon
		if (target instanceof L2Summon)
Index: src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/communitybbs/Manager/RegionBBSManager.java	(working copy)
@@ -225,6 +225,11 @@
					return;
				}

+				if (receiver.isAway())
+				{
+					activeChar.sendMessage(receiver.getName() + " is Away please try again later.");
+					return;
+				}
				if (Config.LOG_CHAT)
				{
					LogRecord record = new LogRecord(Level.INFO, ar3);
@@ -452,6 +457,8 @@

					if (player.isGM())
						htmlCode.append("<font color=\"LEVEL\">" + player.getName() + "</font>");
+					else if(player.isAway() && Config.ALT_ALLOW_AWAY_STATUS)
+						htmlCode.append(player.getName() + "*Away*");
					else if (player.getClan() != null && player.isClanLeader() && Config.SHOW_CLAN_LEADER
							&& player.getClan().getLevel() >= Config.SHOW_CLAN_LEADER_CLAN_LEVEL)
						htmlCode.append("<font color=\"00FF00\">" + player.getName() + "</font>");
Index: src/main/java/com/l2jfree/gameserver/GameServer.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/GameServer.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/GameServer.java	(working copy)
@@ -67,6 +67,7 @@
import com.l2jfree.gameserver.handler.VoicedCommandHandler;
import com.l2jfree.gameserver.idfactory.IdFactory;
import com.l2jfree.gameserver.instancemanager.AuctionManager;
+import com.l2jfree.gameserver.instancemanager.AwayManager;
import com.l2jfree.gameserver.instancemanager.BoatManager;
import com.l2jfree.gameserver.instancemanager.CastleManager;
import com.l2jfree.gameserver.instancemanager.CastleManorManager;
@@ -328,6 +329,11 @@
			FactionManager.getInstance();
			FactionQuestManager.getInstance();
		}
+		if (Config.ALT_ALLOW_AWAY_STATUS)
+		{
+			Util.printSection("Away System");
+			AwayManager.getInstance();
+		}
		try
		{
			DynamicExtension.getInstance();
Index: src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/handler/chathandlers/ChatWhisper.java	(working copy)
@@ -52,6 +52,14 @@
		{
			if ((!receiver.getMessageRefusal() && !BlockList.isBlocked(receiver, activeChar)) || activeChar.isGM())
			{
+				if (receiver.isAway())
+				{
+					receiver.sendPacket(new CreatureSay(activeChar.getObjectId(), chatType.getId(), activeChar.getName(), text));
+					activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(),  chatType.getId(), "->" + receiver.getName(), text));
+					SystemMessage sm = new SystemMessage(SystemMessageId.S1);
+					sm.addString(target + " is Away try again later");
+					activeChar.sendPacket(sm);
+				}
				if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
				{
					activeChar.sendMessage(receiver.getName()+" is currently in jail.");
Index: src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java	(working copy)
@@ -45,6 +45,10 @@
	private VoicedCommandHandler()
	{
		_datatable = new FastMap<String, IVoicedCommandHandler>();
+		if (Config.ALT_ALLOW_AWAY_STATUS)
+		{
+			registerVoicedCommandHandler(new Away());
+		}
		registerVoicedCommandHandler(new CastleDoors());
		registerVoicedCommandHandler(new Hellbound());
		registerVoicedCommandHandler(new VersionInfo());
Index: src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java	(revision 0)
+++ src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Away.java	(revision 0)
@@ -0,0 +1,152 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfree.gameserver.handler.voicedcommandhandlers;
+
+import com.l2jfree.Config;
+import com.l2jfree.gameserver.handler.IVoicedCommandHandler;
+import com.l2jfree.gameserver.instancemanager.AwayManager;
+import com.l2jfree.gameserver.instancemanager.SiegeManager;
+import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfree.gameserver.model.entity.Siege;
+import com.l2jfree.gameserver.model.zone.L2Zone;
+
+/** 
+ * @author Michiru
+ * 
+ */
+public class Away implements IVoicedCommandHandler
+{
+	private static final String[]	VOICED_COMMANDS	=
+													{ "away", "back" };
+
+	/* (non-Javadoc)
+	 * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(String, com.l2jfree.gameserver.model.L2PcInstance), String)
+	 */
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String text)
+	{
+		if (command.startsWith("away"))
+			return away(activeChar, text);
+		else if (command.startsWith("back"))
+			return back(activeChar);
+		return false;
+	}
+
+	/* (non-Javadoc)
+	 * @see com.l2jfree.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
+	 */
+
+	private boolean away(L2PcInstance activeChar, String text)
+	{
+		Siege siege = SiegeManager.getInstance().getSiege(activeChar);
+		//check char is all ready in away mode
+		if (activeChar.isAway())
+		{
+			activeChar.sendMessage("You are allready Away");
+			return false;
+		}
+		
+		if (!activeChar.isInsideZone(L2Zone.FLAG_PEACE) && Config.ALT_AWAY_PEACE_ZONE)
+		{
+			activeChar.sendMessage("You can only Away in Peace Zone");
+			return false;
+		}
+		if (activeChar.isTransformed())
+		{
+			activeChar.sendMessage("You cannot go Away while transformed");
+			return false;
+		}
+		//check player is death/fake death and movement disable
+		if (activeChar.isMovementDisabled() || activeChar.isAlikeDead())
+			return false;
+		// Check if player is in Siege
+		if (siege != null && siege.getIsInProgress())
+		{
+			activeChar.sendMessage("You are in siege, you can't go Afk.");
+			return false;
+		}
+		// Check if player is a Cursed Weapon owner
+		if (activeChar.isCursedWeaponEquipped())
+		{
+			activeChar.sendMessage("You can't go Afk! You are currently holding a cursed weapon.");
+			return false;
+		}
+		// Check if player is in Duel
+		if (activeChar.isInDuel())
+		{
+			activeChar.sendMessage("You can't go Afk! You are in a duel!");
+			return false;
+		}
+		//check is in DimensionsRift
+		if (activeChar.isInParty() && activeChar.getParty().isInDimensionalRift())
+		{
+			activeChar.sendMessage("You can't go Afk! You are in the dimensional rift.");
+			return false;
+		}
+		// Check to see if the player is in an event
+		if (activeChar.isInFunEvent())
+		{
+			activeChar.sendMessage("You can't go Afk! You are in event now.");
+			return false;
+		}
+		//check player is in Olympiade
+		if (activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() != -1)
+		{
+			activeChar.sendMessage("You can't go Afk! Your are fighting in Olympiad!");
+			return false;
+		}
+		// Check player is in observer mode
+		if (activeChar.inObserverMode())
+		{
+			activeChar.sendMessage("You can't go Afk in Observer mode!");
+			return false;
+		}
+		//check player have karma/pk/pvp status
+		if (activeChar.getKarma() > 0 || activeChar.getPvpFlag() > 0)
+		{
+			activeChar.sendMessage("Player in PVP or with Karma can't use the Away command!");
+			return false;
+		}
+		if (activeChar.isImmobilized())
+			return false;
+		//check away text have not more then 10 letter
+		if (text.length() > 10)
+		{
+			activeChar.sendMessage("You can't set your status Away with more then 10 letters");
+			return false;
+		}
+		// check if player have no one in target
+		if (activeChar.getTarget() == null && text.length() <= 1 || text.length() <= 10)
+
+			//set this Player status away in AwayManager
+			AwayManager.getInstance().setAway(activeChar, text);
+		return true;
+	}
+
+	private boolean back(L2PcInstance activeChar)
+	{
+		if (!activeChar.isAway())
+		{
+			activeChar.sendMessage("You are not Away!");
+			return false;
+		}
+		AwayManager.getInstance().setBack(activeChar);
+		return true;
+	}
+
+	public String[] getVoicedCommandList()
+	{
+		return VOICED_COMMANDS;
+	}
+}
Index: src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java	(revision 0)
+++ src/main/java/com/l2jfree/gameserver/instancemanager/AwayManager.java	(revision 0)
@@ -0,0 +1,186 @@
+/*
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ * 
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package com.l2jfree.gameserver.instancemanager;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.l2jfree.Config;
+import com.l2jfree.gameserver.ThreadPoolManager;
+import com.l2jfree.gameserver.ai.CtrlIntention;
+import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jfree.gameserver.network.serverpackets.SetupGauge;
+import com.l2jfree.gameserver.network.serverpackets.SocialAction;
+
+/**
+ * @author Michiru
+ *
+ */
+public final class AwayManager
+{
+	private static final Log				_log	= LogFactory.getLog(AwayManager.class.getName());
+	private static AwayManager				_instance;
+	private Map<L2PcInstance, RestoreData>	_awayPlayers;
+
+	public static final AwayManager getInstance()
+	{
+		if (_instance == null)
+		{
+			_instance = new AwayManager();
+			_log.info("AwayManager: initialized.");
+		}
+		return _instance;
+	}
+
+	private final class RestoreData
+	{
+		private final String	_originalTitle;
+		private final int		_originalTitleColor;
+		private final boolean	_sitForced;
+
+		public RestoreData(L2PcInstance activeChar)
+		{
+			_originalTitle = activeChar.getTitle();
+			_originalTitleColor = activeChar.getAppearance().getTitleColor();
+			_sitForced = !activeChar.isSitting();
+		}
+
+		public boolean isSitForced()
+		{
+			return _sitForced;
+		}
+
+		public void restore(L2PcInstance activeChar)
+		{
+			activeChar.getAppearance().setTitleColor(_originalTitleColor);
+			activeChar.setTitle(_originalTitle);
+		}
+	}
+
+	private AwayManager()
+	{
+		_awayPlayers = Collections.synchronizedMap(new WeakHashMap<L2PcInstance, RestoreData>());
+	}
+
+	/**
+	 * @param activeChar
+	 * @param text
+	 */
+	public void setAway(L2PcInstance activeChar, String text)
+	{
+		activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 9));
+		activeChar.sendMessage("Your status is Away in " + Config.ALT_AWAY_TIMER + " Sec.");
+		activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
+		SetupGauge sg = new SetupGauge(SetupGauge.BLUE, Config.ALT_AWAY_TIMER * 1000);
+		activeChar.sendPacket(sg);
+		activeChar.setIsImmobilized(true);
+		ThreadPoolManager.getInstance().scheduleGeneral(new setPlayerAwayTask(activeChar, text), Config.ALT_AWAY_TIMER * 1000);
+	}
+
+	/**
+	 * @param activeChar
+	 */
+	public void setBack(L2PcInstance activeChar)
+	{
+		activeChar.sendMessage("You are back from Away Status in " + Config.ALT_BACK_TIMER + " Sec.");
+		SetupGauge sg = new SetupGauge(SetupGauge.BLUE, Config.ALT_BACK_TIMER * 1000);
+		activeChar.sendPacket(sg);
+		ThreadPoolManager.getInstance().scheduleGeneral(new setPlayerBackTask(activeChar), Config.ALT_BACK_TIMER * 1000);
+	}
+
+	class setPlayerAwayTask implements Runnable
+	{
+
+		private final L2PcInstance	_activeChar;
+		private final String		_awayText;
+
+		setPlayerAwayTask(L2PcInstance activeChar, String awayText)
+		{
+			_activeChar = activeChar;
+			_awayText = awayText;
+		}
+
+		public void run()
+		{
+			if (_activeChar == null)
+				return;
+			if (_activeChar.isAttackingNow() || _activeChar.isCastingNow())
+				return;
+
+			_awayPlayers.put(_activeChar, new RestoreData(_activeChar));
+
+			_activeChar.disableAllSkills();
+			_activeChar.abortAttack();
+			_activeChar.abortCast();
+			_activeChar.setTarget(null);
+			_activeChar.setIsImmobilized(false);
+			if (!_activeChar.isSitting())
+				_activeChar.sitDown(true);
+			if (_awayText.length() <= 1)
+			{
+				_activeChar.sendMessage("You are now *Away*");
+			}
+			else
+			{
+				_activeChar.sendMessage("You are now Away *" + _awayText + "*");
+			}
+			_activeChar.getAppearance().setTitleColor(Config.ALT_AWAY_TITLE_COLOR);
+			if (_awayText.length() <= 1)
+			{
+				_activeChar.setTitle("*Away*");
+			}
+			else
+			{
+				_activeChar.setTitle("Away*" + _awayText + "*");
+			}
+			_activeChar.broadcastUserInfo();
+			_activeChar.setIsParalyzed(true);
+			_activeChar.setIsAway(true);
+		}
+	}
+
+	class setPlayerBackTask implements Runnable
+	{
+
+		private final L2PcInstance	_activeChar;
+
+		setPlayerBackTask(L2PcInstance activeChar)
+		{
+			_activeChar = activeChar;
+		}
+
+		public void run()
+		{
+			if (_activeChar == null)
+				return;
+			RestoreData rd = _awayPlayers.get(_activeChar);
+			if (rd == null)
+				return;
+			_activeChar.setIsParalyzed(false);
+			_activeChar.enableAllSkills();
+			_activeChar.setIsAway(false);
+			if (rd.isSitForced())
+				_activeChar.standUp();
+			rd.restore(_activeChar);
+			_awayPlayers.remove(_activeChar);
+			_activeChar.broadcastUserInfo();
+			_activeChar.sendMessage("You are Back now!");
+		}
+	}
+}
Index: src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -752,6 +752,11 @@

	private int								_clientRevision			= 0;

+	/** character away mode **/
+	private boolean							_isAway					= false;
+	public int								_originalTitleColorAway;
+	public String							_originalTitleAway;
+
	private FactionMember					_faction;

	/* Flag to disable equipment/skills while wearing formal wear **/
@@ -2784,6 +2789,8 @@
		{
			sendMessage("A dark force beyond your mortal understanding makes your knees to shake when you try to stand up ...");
		}
+		else if (isAway())
+			sendMessage("You can't stand up if your Status is Away");
		else if (TvT._sitForced && _inEventTvT || CTF._sitForced && _inEventCTF || DM._sitForced && _inEventDM || VIP._sitForced && _inEventVIP)
			sendMessage("The Admin/GM handle if you sit or stand in this match!");
		else if (_waitTypeSitting && !isInStoreMode() && !isAlikeDead() && (!_protectedSitStand || force))
@@ -3735,6 +3742,12 @@
			return;
		}

+		if (isAway() && !Config.ALT_AWAY_ALLOW_INTERFERENCE)
+		{
+			sendMessage("You can't target Away Players");
+			sendPacket(ActionFailed.STATIC_PACKET);
+			return;
+		}
		if (Config.SIEGE_ONLY_REGISTERED)
		{
			if (!canBeTargetedByAtSiege(player))
@@ -12995,7 +13008,17 @@
	{
		_olympiadOpponentId = value;
	}
-	
+
+	public boolean isAway()
+	{
+		return _isAway;
+	}
+
+	public void setIsAway(boolean state)
+	{
+		_isAway = state;
+	}
+
	private ImmutableReference<L2PcInstance> _immutableReference;
	private ClearableReference<L2PcInstance> _clearableReference;

Index: src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/network/clientpackets/Logout.java	(working copy)
@@ -78,6 +78,13 @@
            player.sendMessage("You can not log out while flying.");
            return;
        }
+
+		if (player.isAway())
+		{
+			player.sendMessage("You can't logout in Away mode.");
+			return;
+		}
+
        // [L2J_JP ADD END]

        if(AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !player.isGM())
Index: src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/network/clientpackets/RequestRestart.java	(working copy)
@@ -66,6 +66,12 @@
            return;
        }

+		if (player.isAway())
+		{
+			player.sendMessage("You can't restart in Away mode.");
+			return;
+		}
+
        if(player.atEvent)
        {
            player.sendMessage("A superior power doesn't allow you to leave the event.");
Index: src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java
===================================================================
--- src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java	(revision 4757)
+++ src/main/java/com/l2jfree/gameserver/network/L2IrcClient.java	(working copy)
@@ -337,8 +337,11 @@
					boolean _isFirst = true;
					for (L2PcInstance player : L2World.getInstance().getAllPlayers())
					{
-						_onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName();
-						_isFirst = false;
+						if (player.isAway())
+							_onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName() + "*Away*";
+						else
+							_onlineNames = _onlineNames + (_isFirst ? " " : ", ") + player.getName();
+							_isFirst = false;
					}
					sendChan(_onlineNames);
				}

Posted

if server fulls of announcements then its suck....

althought its a good search the announce is bad point...

My friend, my lovely Friend. Pay attention to what we said read what we said. You can avoid Spamming. :D and is not seach is share :D

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.



×
×
  • Create New...