Welcome to MaxCheaters.com

Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads

Code Remove Buffs And Debuffs Item


Recommended Posts

so in frozen there is a gm command that shows u ur buffs/debuffs and u can cancel em by pressing remove.

so i did that for the players. u press a item and a html shows up with all ur bufflist and u are able to remove any buff that u want.

i made it with an item press cauze i had smthing else in my mind but u can make it with command ;d

 

so.

gameserver/handler/itemhandlers

create file also dont forget to register it

package com.l2jfrozen.gameserver.handler.itemhandlers;

import javolution.text.TextBuilder;

import com.l2jfrozen.gameserver.handler.IItemHandler;
import com.l2jfrozen.gameserver.model.L2Effect;
import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;

public class BuffRemove implements IItemHandler
{

	public BuffRemove()
	{
	//null
	}

	@Override
	public void useItem(L2PlayableInstance playable, L2ItemInstance item)
	{

			if(!(playable instanceof L2PcInstance))
				return;

			L2PcInstance activeChar = (L2PcInstance) playable;
			
    		if (!activeChar.getFloodProtectors().getDropItem().tryPerformAction("Use"))
    		{
    			activeChar.sendPacket(ActionFailed.STATIC_PACKET);
    			return;
    		}

				if(activeChar.getKarma() > 0 || activeChar.getPvpFlag() > 0 || activeChar.isInCombat())
				{
					activeChar.sendMessage("You cannot use the bufflist view right now");
					return;
				}
				
				if(activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() != -1)
				{
					activeChar.sendMessage("You cannot use the bufflist view right now");
					return;
				}
			
			else
			{
		    	   showBuffs(activeChar, activeChar);
			}
			activeChar = null;
		}
	
   	public void showBuffs(L2PcInstance player, L2PcInstance activeChar)
	{
		
		TextBuilder html = new TextBuilder();

		html.append("<html><head><title>Character Buffs</title></head>");
		html.append("<body>");      
		html.append("<center>");
		html.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"999999\">");
		html.append("<tr>");
		html.append("<td align=\"center\"><font color=\"FF4400\">My buff list</font>");
		html.append("<br1><font color=\"333333\">You can remove any buff you want</font>");
		html.append("<br1><font color=\"333333\">Debuffs can be removed too</font>");
		html.append("<br1><font color=\"333333\">Cannot be used while you are in oly or in pvp</font></td>");
		html.append("</tr>");
		html.append("</table>");
		html.append("</center>");
		html.append("<br>");
		html.append("<img src=\"l2ui.squaregray\" width=\"300\" height=\"1\">");
		html.append("<table>");
		html.append("<tr><td width=215><font color=\"FF6600\">SkillName</td><td width=55>Action</font></td></tr>");
		html.append("</table>");
		html.append("<img src=\"l2ui.squaregray\" width=\"300\" height=\"1\">");
		html.append("<table>");
		html.append("<tr><td width=200></td><td width=70></td></tr>");

		L2Effect[] effects = player.getAllEffects();

		for(L2Effect e : effects)
		{
			if(e != null)
			{
				html.append("<tr><td><font color=\"666666\">" + e.getSkill().getName() + "</font></td><td><button value=\"Remove\" action=\"bypass -h stopbuff " + player.getName() + " " + String.valueOf(e.getSkill().getId()) + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
			}
		}

		html.append("</table><br>");
		html.append("<center>");
		html.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32 align=center><br>");
		html.append("</center>");
		html.append("</html>");

		NpcHtmlMessage ms = new NpcHtmlMessage(1);
		ms.setHtml(html.toString());

		activeChar.sendPacket(ms);

		html = null;
		ms = null;
		effects = null;
	}

	@Override
	public int[] getItemIds()
	{
		return ITEM_IDS;
	}

	private static final int ITEM_IDS[] =
	{
		6392
	};

}

now network/clientpacks/RequestBypassToServer.java

find this

			else if (_command.startsWith("OlympiadArenaChange"))
			{
				Olympiad.bypassChangeArena(_command, activeChar);
			}

below add

			if (_command.startsWith("stopbuff"))
			{
				StringTokenizer st = new StringTokenizer(_command);
				st.nextToken();
				try
				{
					if(st.hasMoreTokens())
					{
						String playername = st.nextToken();

						if(st.hasMoreTokens()){
							
							int SkillId = 0;
							
							try{
								SkillId = Integer.parseInt(st.nextToken());

							}catch(NumberFormatException e){

								return;
								
							}
							
							if(SkillId>0)
								removeBuff(activeChar, playername, SkillId);
							else{
								return;
							}
							
							st = null;
							playername = null;

							return;
							
							
						}
						return;
					}
					return;
				}
				catch (StringIndexOutOfBoundsException e)
				{
				}
			}

now find private void comeHere(L2PcInstance activeChar) and above add the code

	public void showBuffs(L2PcInstance player, L2PcInstance activeChar)
	{
		
		if(activeChar.getKarma() > 0 || activeChar.getPvpFlag() > 0 || activeChar.isInCombat())
		{
			activeChar.sendMessage("You cannot use the bufflist view right now");
			return;
		}
		
		if(activeChar.isInOlympiadMode() || activeChar.getOlympiadGameId() != -1)
		{
			activeChar.sendMessage("You cannot use the bufflist view right now");
			return;
		}
		
		TextBuilder html = new TextBuilder();

		html.append("<html><head><title>Character Buffs</title></head>");
		html.append("<body>");      
		html.append("<center>");
		html.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"999999\">");
		html.append("<tr>");
		html.append("<td align=\"center\"><font color=\"FF4400\">My buff list</font>");
		html.append("<br1><font color=\"333333\">You can remove any buff you want</font>");
		html.append("<br1><font color=\"333333\">Debuffs can be removed too</font>");
		html.append("<br1><font color=\"333333\">Cannot be used while you are in oly or in pvp</font></td>");
		html.append("</tr>");
		html.append("</table>");
		html.append("</center>");
		html.append("<br>");
		html.append("<img src=\"l2ui.squaregray\" width=\"300\" height=\"1\">");
		html.append("<table>");
		html.append("<tr><td width=215><font color=\"FF6600\">SkillName</td><td width=65>Action</font></td></tr>");
		html.append("</table>");
		html.append("<img src=\"l2ui.squaregray\" width=\"300\" height=\"1\">");
		html.append("<table>");
		html.append("<tr><td width=200></td><td width=70></td></tr>");

		L2Effect[] effects = player.getAllEffects();

		for(L2Effect e : effects)
		{
			if(e != null)
			{
				html.append("<tr><td><font color=\"666666\">" + e.getSkill().getName() + "</font></td><td><button value=\"Remove\" action=\"bypass -h stopbuff " + player.getName() + " " + String.valueOf(e.getSkill().getId()) + "\" width=60 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
			}
		}

		html.append("</table><br>");
		html.append("<center>");
		html.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32 align=center><br>");
		html.append("</center>");
		html.append("</html>");

		NpcHtmlMessage ms = new NpcHtmlMessage(1);
		ms.setHtml(html.toString());

		activeChar.sendPacket(ms);

		html = null;
		ms = null;
		effects = null;
	}
	
	private void removeBuff(L2PcInstance remover, String playername, int SkillId)
	{
		L2PcInstance player = L2World.getInstance().getPlayer(playername);
		
		if(player.getKarma() > 0 || player.getPvpFlag() > 0 || player.isInCombat())
		{
			player.sendMessage("You cannot remove buffs right now");
			return;
		}
		
		if(player.isInOlympiadMode() || player.getOlympiadGameId() != -1)
		{
			player.sendMessage("You cannot remove buffs right now");
			return;
		}

		if(player != null && SkillId > 0)
		{
			L2Effect[] effects = player.getAllEffects();

			for(L2Effect e : effects)
			{
				if(e != null && e.getSkill().getId() == SkillId)
				{
					e.exit(true);
				}
			}
			showBuffs(player, remover);

			player = null;
			effects = null;
		}
	}

the item id is 6392. u cant use it in olympiad or when u are flagged, in combat or with karma

Share this post


Link to post
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.