Jump to content

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


Recommended Posts

  • 3 weeks later...
  • 11 months later...
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.actor.L2Character;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2SummonInstance;

/**
 * @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 on NPCs!");
               return false;
            }
            L2Object targetm = activeChar.getTarget();
            if (targetm instanceof L2MonsterInstance)
            {
                activeChar.sendMessage("You can not use it on Monsters/RaidBosses!");
                return false;
            }
            L2Object targets = activeChar.getTarget();
            if (targets instanceof L2SummonInstance)
            {
                activeChar.sendMessage("You can not use it on Summons!");
                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 on NPCs!");
               return false;
            }
            L2Object targetm = activeChar.getTarget();
            if (targetm instanceof L2MonsterInstance)
            {
                activeChar.sendMessage("You can not use it on Monsters/RaidBosses!");
                return false;
            }
            L2Object targets = activeChar.getTarget();
            if (targets instanceof L2SummonInstance)
            {
                activeChar.sendMessage("You can not use it on Summons!");
                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().getKnownTypeInRadius(L2Character.class, 480);
            for (L2Character p : players)
            {
                if (p instanceof L2PcInstance)
                {
                    ((L2PcInstance) p).sitDown();
                }
            }
        }
        
        if (command.startsWith("admin_rangestand"))
        {
            Collection <L2Character> players = activeChar.getKnownList().getKnownTypeInRadius(L2Character.class, 480);
            for (L2Character p : players)
            {
                if (p instanceof L2PcInstance)
                {
                    ((L2PcInstance) p).standUp();
                }
            }
                
        }
    return true;

    }

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

I just fixed a bit for acis and added some check for summons and monsters now.

Link to comment
Share on other sites

  • 3 weeks later...

package l2r.gameserver.scripts.handlers.admincommandhandlers;

import l2r.gameserver.handler.IAdminCommandHandler;
import l2r.gameserver.model.L2Object;
import l2r.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();
			L2PcInstance player = null;
			if (target instanceof L2PcInstance)
			{
				player = (L2PcInstance) target;
			}
			else
			{
				activeChar.sendMessage("No target found");
				return false;
			}
			if (!activeChar.isSitting())
			{
				player.sitDown();
			}
		}
		else if (command.startsWith("stand"))
		{
			L2Object target = activeChar.getTarget();
			L2PcInstance player = null;
			if (target instanceof L2PcInstance)
			{
				player = (L2PcInstance) target;
			}
			else
			{
				activeChar.sendMessage("No target found");
				return false;
			}
			if (activeChar.isSitting())
			{
				player.standUp();
			}
		}
		else if (command.startsWith("rangesit"))
		{
			for (L2PcInstance p : activeChar.getKnownList().getKnownPlayersInRadius(240))
			{
				if ((p != null) && !p.isSitting())
				{
					p.sitDown();
				}
			}
		}
		else if (command.startsWith("rangestand"))
		{
			
			for (L2PcInstance pPc : activeChar.getKnownList().getKnownPlayersInRadius(240))
			{
				if ((pPc != null) && pPc.isSitting())
				{
					pPc.standUp();
				}
			}
			
		}
		return true;
	}
	
	@Override
	public String[] getAdminCommandList()
	{
		return ADMIN_COMMANDS;
	}
}

Better so many casts for nothing..

Edited by Ovenuç®
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.
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...