Page 1 of 1

How can I force all players around me to sit?

Posted: Sat Dec 19, 2009 11:14 pm
by prisoneer
How can I force all players around me to sit?
command?? skill effect??

how can I do this?

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 12:39 am
by Lee
if (;)
{
player.stopMove(null, false);
player.abortAttack();
player.abortCast();

if (!player.isSitting())
player.sitDown();
}
else
{
if (player.isSitting())
player.standUp();
}

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 12:47 pm
by devo
Patch:

Code: Select all

### Eclipse Workspace Patch 1.0#P datapack_developmentIndex: data/scripts/handlers/admincommandhandlers/AdminSit.java===================================================================--- data/scripts/handlers/admincommandhandlers/AdminSit.java	(revision 0)+++ data/scripts/handlers/admincommandhandlers/AdminSit.java	(revision 0)@@ -0,0 +1,227 @@+/*+ * 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 handlers.admincommandhandlers;++import java.util.StringTokenizer;+import net.sf.l2j.gameserver.handler.IAdminCommandHandler;+import net.sf.l2j.gameserver.model.L2Object;+import net.sf.l2j.gameserver.model.L2World;+import net.sf.l2j.gameserver.model.actor.L2Character;+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;+import net.sf.l2j.gameserver.network.SystemMessageId;+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;++/**+ * + * author devO+ * + * This class handles following admin commands:+ * - sit = force target L2Character to sit+ * - stand = force target L2Character to stand+ *+ * - sit <radius> = If radius is specified, then ALL players only in that radius will sit.+ * - stand <radius> = If radius is specified, then ALL players only in that radius will stand.+ *+ */+public class AdminSit implements IAdminCommandHandler+{+	private static final String[] ADMIN_COMMANDS =+	{+		"admin_sit",+		"admin_stand"+	};+	+	public boolean useAdminCommand(String command, L2PcInstance activeChar)+	{+		if (command.startsWith("admin_sit"))+		{+			StringTokenizer st = new StringTokenizer(command, " ");+			st.nextToken(); // skip command+			+			if (st.hasMoreTokens())+			{+				String firstParam = st.nextToken();+				L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);+				if (plyr != null)+				{+					if (st.hasMoreTokens())+					{+						try+						{+							int radius = Integer.parseInt(st.nextToken());+							for (L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))+							{+								if (knownChar == activeChar)+									continue;+								+								sit(activeChar, knownChar);+							}+							+							activeChar.sendMessage("All characters within a " + radius + " unit radius forced to sit.");+							return true;+						}+						catch (NumberFormatException e)+						{+							activeChar.sendMessage("Invalid radius.");+							return false;+						}+					}+					else+					{+						sit(activeChar, plyr);+					}+				}+				else+				{+					try+					{+						int radius = Integer.parseInt(firstParam);+						+						for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))+						{+							if (knownChar == activeChar)+								continue;+							sit(activeChar, knownChar);+						}+						+						activeChar.sendMessage("All characters within a " + radius + " unit radius forced to sit.");+						return true;+					}+					catch (NumberFormatException e)+					{+						activeChar.sendMessage("Usage: //sit <player_name | radius>");+						return false;+					}+				}+			}+			else+			{+				L2Object obj = activeChar.getTarget();+				if (!(obj instanceof L2PcInstance))+					activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));+				else+				{+					sit(activeChar, (L2Character) obj);+				}+			}+		}+		else if (command.startsWith("admin_stand"))+		{+			StringTokenizer st = new StringTokenizer(command, " ");+			st.nextToken(); // skip command+			+			if (st.hasMoreTokens())+			{+				String firstParam = st.nextToken();+				L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);+				if (plyr != null)+				{+					if (st.hasMoreTokens())+					{+						try+						{+							int radius = Integer.parseInt(st.nextToken());+							for (L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))+							{+								if (knownChar == activeChar)+									continue;+								+								stand(activeChar, knownChar);+							}+							+							activeChar.sendMessage("All characters within a " + radius + " unit radius forced to stand.");+							return true;+						}+						catch (NumberFormatException e)+						{+							activeChar.sendMessage("Invalid radius.");+							return false;+						}+					}+					else+					{+						stand(activeChar, plyr);+					}+				}+				else+				{+					try+					{+						int radius = Integer.parseInt(firstParam);+						+						for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))+						{+							if (knownChar == activeChar)+								continue;+							stand(activeChar, knownChar);+						}+						+						activeChar.sendMessage("All characters within a " + radius + " unit radius forced to stand.");+						return true;+					}+					catch (NumberFormatException e)+					{+						activeChar.sendMessage("Usage: //stand <player_name | radius>");+						return false;+					}+				}+			}+			else+			{+				L2Object obj = activeChar.getTarget();+				if (!(obj instanceof L2PcInstance))+					activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));+				else+				{+					stand(activeChar, (L2Character) obj);+				}+			}+		}+		return true;+	}+	+	private void sit(L2PcInstance activeChar, L2Character target)+	{+		if (target instanceof L2PcInstance)+		{+			target.stopMove(null, false);+			target.abortAttack();+			target.abortCast();+			if (!((L2PcInstance) target).isSitting())+			{+				((L2PcInstance) target).sitDown();+			}+		}+	}+	+	private void stand(L2PcInstance activeChar, L2Character target)+	{+		if (target instanceof L2PcInstance)+		{+			target.stopMove(null, false);+			target.abortAttack();+			target.abortCast();+			if (((L2PcInstance) target).isSitting())+			{+				((L2PcInstance) target).standUp();+			}+		}+	}+	+	public String[] getAdminCommandList()+	{+		return ADMIN_COMMANDS;+	}+}Index: data/scripts/handlers/MasterHandler.java===================================================================--- data/scripts/handlers/MasterHandler.java	(revision 6775)+++ data/scripts/handlers/MasterHandler.java	(working copy)@@ -92,6 +94,7 @@ 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShop()); 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShutdown()); 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSiege());+		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSit()); 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSkill()); 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSpawn()); 		AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSummon()); 
dont forget to add commands in sql:

Code: Select all

INSERT IGNORE INTO `admin_command_access_rights` VALUES('admin_sit','1'),('admin_stand','1');

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 6:45 pm
by jurchiks
hey, that's some useful stuff, thx :)
just 1 question: can they stand up by themselves after forced to sit?
Edit: maybe you could add a function to stop all players in the radius from casting skills too? that would be like in school :D

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 8:17 pm
by devo
jurchiks wrote: just 1 question: can they stand up by themselves after forced to sit?
yes
jurchiks wrote: Edit: maybe you could add a function to stop all players in the radius from casting skills too? that would be like in
only to stop casting?

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 10:09 pm
by jurchiks
well, it would be better to disallow casting for a set number of time, seconds probably, but there is a number of problems
but i guess canceling for just that moment is easier
about that sit/stand - better to disallow standing by themselves, if you want it for an event, like dice, then you don't want them switching places, running around etc...
that would probably require some kind of toggle admin skill though :)

Re: How can I force all players around me to sit?

Posted: Sun Dec 20, 2009 11:07 pm
by Tan
For event l2j have implanted //event commend with you can spawn a npc nearest players then summon they and force them to sit trough // event_panel

Re: How can I force all players around me to sit?

Posted: Mon Dec 21, 2009 1:18 am
by devo
jurchiks wrote:well, it would be better to disallow casting for a set number of time, seconds probably, but there is a number of problems
but i guess canceling for just that moment is easier
its not a problem to make it, if you want I can make it also.
jurchiks wrote: about that sit/stand - better to disallow standing by themselves, if you want it for an event, like dice, then you don't want them switching places, running around etc...
that would probably require some kind of toggle admin skill though :)
isnt there a //para <radius> command?

Re: How can I force all players around me to sit?

Posted: Mon Dec 21, 2009 9:42 pm
by jurchiks
i'm just making suggestions, i don't need it, but maybe someone else will
it's good that you can :)