How can I force all players around me to sit?

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
prisoneer
Posts: 8
Joined: Wed Oct 28, 2009 12:14 am

How can I force all players around me to sit?

Post by prisoneer »

How can I force all players around me to sit?
command?? skill effect??

how can I do this?
Lee
Posts: 102
Joined: Wed Sep 02, 2009 11:10 pm

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

Post by Lee »

if (;)
{
player.stopMove(null, false);
player.abortAttack();
player.abortCast();

if (!player.isSitting())
player.sitDown();
}
else
{
if (player.isSitting())
player.standUp();
}
User avatar
devo
Posts: 798
Joined: Mon Jun 15, 2009 1:19 pm

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

Post 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');
A hero of war is that what they see...
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
devo
Posts: 798
Joined: Mon Jun 15, 2009 1:19 pm

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

Post 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?
A hero of war is that what they see...
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post 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 :)
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
User avatar
Tan
L2j Veteran
L2j Veteran
Posts: 873
Joined: Wed Jun 10, 2009 10:31 pm
Location: Poland

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

Post 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
Some people believe in God... i believe in Music... some people pray..... I turn on Winamp
http://www.last.fm/user/L2jTan
User avatar
devo
Posts: 798
Joined: Mon Jun 15, 2009 1:19 pm

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

Post 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?
A hero of war is that what they see...
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

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

Post by jurchiks »

i'm just making suggestions, i don't need it, but maybe someone else will
it's good that you can :)
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Post Reply