2 more admin commands

    Share
    avatar
    Karakan

    Posts : 403
    Join date : 2013-10-04

    2 more admin commands

    Post  Karakan on 3rd September 2015, 15:23

    Additional 2 admin commands to play with.


    //social 1-3 (plays monster social action)

    //effect [skillid] [skillLvl] [hittime] (shows skill animations on target)




    Code:
    Index: AdminEffects.java
    ===================================================================
    --- AdminEffects.java (revision 544)
    +++ AdminEffects.java (working copy)
    @@ -17,6 +17,7 @@
      */
     package net.sf.l2j.gameserver.handler.admincommandhandlers;
     
    +import java.util.Collection;
     import java.util.StringTokenizer;
     
     import net.sf.l2j.Config;
    @@ -25,12 +26,17 @@
     import net.sf.l2j.gameserver.model.L2Character;
     import net.sf.l2j.gameserver.model.L2Object;
     import net.sf.l2j.gameserver.model.L2Skill;
    +import net.sf.l2j.gameserver.model.L2Summon;
    +import net.sf.l2j.gameserver.model.L2World;
    +import net.sf.l2j.gameserver.model.actor.instance.L2ChestInstance;
     import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     import net.sf.l2j.gameserver.serverpackets.CharInfo;
     import net.sf.l2j.gameserver.serverpackets.Earthquake;
    +import net.sf.l2j.gameserver.serverpackets.MagicSkillUse;
     import net.sf.l2j.gameserver.serverpackets.NpcInfo;
     import net.sf.l2j.gameserver.serverpackets.StopMove;
    +import net.sf.l2j.gameserver.serverpackets.SocialAction;
     import net.sf.l2j.gameserver.serverpackets.SystemMessage;
     import net.sf.l2j.gameserver.serverpackets.UserInfo;
     
    @@ -46,7 +52,7 @@
        private static String[] _adminCommands = { "admin_invis", "admin_invisible", "admin_vis",
       "admin_visible", "admin_earthquake", "admin_bighead", "admin_shrinkhead", "admin_gmspeed",
       "admin_unpara_all", "admin_para_all", "admin_unpara", "admin_para", "admin_polyself",
    -   "admin_unpolyself", "admin_clearteams", "admin_setteam" };
    +   "admin_unpolyself", "admin_clearteams", "admin_setteam", "admin_social", "admin_effect" };
     
        private static final int REQUIRED_LEVEL = Config.GM_GODMODE;
     
    @@ -301,9 +307,137 @@
     
                player.broadcastUserInfo();
            }
    + else if (command.startsWith("admin_social"))
    + {
    + try
    + {
    + String target = null;
    + L2Object obj = activeChar.getTarget();
    + if (st.countTokens() == 2)
    + {
    + int social = Integer.parseInt(st.nextToken());
    + target = st.nextToken();
    + if (target != null)
    + {
    + L2PcInstance player = L2World.getInstance().getPlayer(target);
    + if (player != null)
    + {
    + if (performSocial(social, player, activeChar))
    + activeChar.sendMessage(player.getName() + " was affected by your request.");
    + }
    + else
    + {
    + try
    + {
    + int radius = Integer.parseInt(target);
    + Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
    + //synchronized (activeChar.getKnownList().getKnownObjects())
    + {
    + for (L2Object object : objs)
    + if (activeChar.isInsideRadius(object, radius, false, false))
    + performSocial(social, object, activeChar);
    + }
    + activeChar.sendMessage(radius + " units radius affected by your request.");
    + }
    + catch (NumberFormatException nbe)
    + {
    + activeChar.sendMessage("Incorrect parameter");
    + }
    + }
    + }
    + }
    + else if (st.countTokens() == 1)
    + {
    + int social = Integer.parseInt(st.nextToken());
    + if (obj == null)
    + obj = activeChar;
    + if (obj != null)
    + {
    + if (performSocial(social, obj, activeChar))
    + activeChar.sendMessage(obj.getName() + " was affected by your request.");
    + else
    + activeChar.sendMessage("Nothing happened...");
    + }
    + else
    + activeChar.sendMessage("Incorrect target");
    + }
    + else if (!command.contains("menu"))
    + activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
    + }
    + catch (Exception e)
    + {
    + if (Config.DEBUG)
    + e.printStackTrace();
    + }
    + }  
    + else if (command.startsWith("admin_effect"))
    + {
    + try
    + {
    + L2Object obj = activeChar.getTarget();
    + int level = 1, hittime = 1;
    + int skill = Integer.parseInt(st.nextToken());
    + if (st.hasMoreTokens())
    + level = Integer.parseInt(st.nextToken());
    + if (st.hasMoreTokens())
    + hittime = Integer.parseInt(st.nextToken());
    + if (obj == null)
    + obj = activeChar;
    + if (obj != null)
    + {
    + if (!(obj instanceof L2Character))
    + activeChar.sendMessage("Incorrect target");
    + else
    + {
    + L2Character target = (L2Character) obj;
    + target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
    + activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
    + }
    + }
    + else
    + activeChar.sendMessage("Incorrect target.");
    + }
    + catch (Exception e)
    + {
    + activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
    + }
    + }  
            
            return true;
        }
    +  
    + private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
    + {
    + try
    + {
    + if (target instanceof L2Character)
    + {
    + if ((target instanceof L2Summon) || (target instanceof L2ChestInstance))
    + {
    + activeChar.sendMessage("Nothing happened");
    + return false;
    + }
    + if ((target instanceof L2NpcInstance) && (action < 1 || action > 3))
    + {
    + activeChar.sendMessage("Nothing happened");
    + return false;
    + }
    + if ((target instanceof L2PcInstance) && (action < 2 || action > 16))
    + {
    + activeChar.sendMessage("Nothing happened");
    + return false;
    + }
    + L2Character character = (L2Character) target;
    + character.broadcastPacket(new SocialAction(target.getObjectId(), action));
    + }
    + else
    + return false;
    + }
    + catch (Exception e)
    + {
    + }
    + return true;
    + }  
     
        public String[] getAdminCommandList()
        {

    DnR
    Admin
    Admin

    Posts : 985
    Join date : 2012-12-03

    Re: 2 more admin commands

    Post  DnR on 9th September 2015, 00:39

    Added to trunk.
    Had to correct MagicSkillUse to MagicSkillUser.
    Generally, commands worked flawlessly.
    Thanks.
    avatar
    Karakan

    Posts : 403
    Join date : 2013-10-04

    Re: 2 more admin commands

    Post  Karakan on 9th September 2015, 15:12

    This is usefull when fixing/adding monster skills.

    You can't give a mob a skill you want to. (Not all skill animations work for mobs in c4)
    They added more animations on later chronicles.

    Thx for commiting. Wink

    Sponsored content

    Re: 2 more admin commands

    Post  Sponsored content


      Current date/time is 24th July 2017, 09:30