Jump to content

[Share]Sit,stand,rangesit,rangestand Admin Commands


Recommended Posts

//sit - click target and player you target will sit down

//stand - click target and player you target will stand up

//rangesit - players in 240 radius will sit down

//rangestand - players in 240 radius will stand up

 

/**
* 
*/
package handlers.admincommandhandlers;

import java.util.Collection;

import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

/**
* @author Ventic
*
*/
public class AdminSit implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS = { "sit" , "stand", "rangesit", "rangestand" };

@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
	if (command.startsWith("sit"))
	{
		L2Object target = activeChar.getTarget();
		if (target == null)
		{
			activeChar.sendMessage("No target found");
			return false;
		}
		else
		{
				((L2PcInstance) target).sitDown();
		}
		if (command.startsWith("stand"))
		{
			L2Object targetPc = activeChar.getTarget();
			if (targetPc == null)
			{
				activeChar.sendMessage("No target found");
				return false;
			}
			else
			{
					((L2PcInstance) targetPc).standUp();
			}
		}
		if (command.startsWith("rangesit"))
		{
			Collection<L2Character> players = activeChar.getKnownList().getKnownCharactersInRadius(240);

			for (L2Character p : players)
			{
				if (p instanceof L2PcInstance)
				{
					((L2PcInstance) p).sitDown();
				}
				else
				{
					if (p == null)
					{
						activeChar.sendMessage("No players found so close");
						return false;
					}
				}
			}
		}
		if (command.startsWith("rangestand"))
		{
			Collection <L2Character> playersPc = activeChar.getKnownList().getKnownCharactersInRadius(240);

			for (L2Character pPc : playersPc)
			{
				if (pPc instanceof L2PcInstance)
				{
					((L2PcInstance) pPc).standUp();
				}
				else
				{
					if (pPc == null)
					{
						activeChar.sendMessage("No players found so close");
						return false;
					}
				}
			}

		}
	}
	return true;
}

@Override
public String[] getAdminCommandList()
{
	return ADMIN_COMMANDS;
}
}

 

Idea Dialogos

Credits,coded by me

 

ps:dont forget to register it

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

the code is not working... thats the real code

/**
* 
*/
package net.sf.l2j.gameserver.handler.admincommandhandlers;

import java.util.Collection;

import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;

/**
* @author Ventic
*
*/
public class AdminSit implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS = { "admin_sit" , "admin_stand", "admin_rangesit", "admin_rangestand" };

@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
	if (command.startsWith("admin_sit"))
	{
		L2Object target = activeChar.getTarget();
		if (target instanceof L2NpcInstance)
		{
		   activeChar.sendMessage("You can not use it at NPCs!");
               return false;
		}
            else if (target == null)
		{
			activeChar.sendMessage("You have no target!");
            return false;
		}
		else
		{
			((L2PcInstance) target).sitDown();
		}
	}

	if (command.startsWith("admin_stand"))
	{
		L2Object target = activeChar.getTarget();
		if (target instanceof L2NpcInstance)
		{
		   activeChar.sendMessage("You can not use it at NPCs!");
               return false;
		}
            else if (target == null)
		{
			activeChar.sendMessage("You have no target!");
            return false;
		}
		else
		{
			((L2PcInstance) target).standUp();
		}
	}

	if (command.startsWith("admin_rangesit"))
	{
		Collection<L2Character> players = activeChar.getKnownList().getKnownCharactersInRadius(240);
		for (L2Character p : players)
		{
			if (p instanceof L2PcInstance)
			{
				((L2PcInstance) p).sitDown();
			}
		}
	}

	if (command.startsWith("admin_rangestand"))
	{
		Collection <L2Character> players = activeChar.getKnownList().getKnownCharactersInRadius(240);
		for (L2Character p : players)
		{
			if (p instanceof L2PcInstance)
			{
				((L2PcInstance) p).standUp();
			}
		}

	}
return true;

}

@Override
public String[] getAdminCommandList()
{
	return ADMIN_COMMANDS;
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...