Jump to content

Question

Posted (edited)

Hello i have this code  but i cant make it work with % chance on item if anyone can help

 

package net.sf.l2j.gameserver.handler.voicedcommandhandlers;

import java.util.StringTokenizer;

import net.sf.l2j.commons.lang.StringUtil;

import net.sf.l2j.gameserver.datatables.ItemTable;
import net.sf.l2j.gameserver.datatables.NpcTable;
import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.item.DropCategory;
import net.sf.l2j.gameserver.model.item.DropData;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;


public class ShiftClickToNpc implements IVoicedCommandHandler
{
	
	private static final int PAGE_LIMIT = 20;
	
	private static String[] _voicedCommands =
	{
		"show_droplist"
	};
	
	@Override
	public boolean useVoicedCommand(String command, Player activeChar, String target)
	{
		final StringTokenizer st = new StringTokenizer(command, " ");
		st.nextToken();
		
		if (command.startsWith("show_droplist"))
		{
			try
			{
				int npcId = Integer.parseInt(st.nextToken());
				int page = (st.hasMoreTokens()) ? Integer.parseInt(st.nextToken()) : 1;
				
				showNpcDropList(activeChar, npcId, page);
			}
			catch (Exception e)
			{
				activeChar.sendMessage("Usage: .show_droplist <npc_id> [<page>]");
			}
		}
		return true;
	}
	
	private static void showNpcDropList(Player activeChar, int npcId, int page)
	{
		final NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
		if (npcData == null)
		{
			activeChar.sendMessage("Npc template is unknown for id: " + npcId + ".");
			return;
		}
		
		final StringBuilder sb = new StringBuilder(2000);
		StringUtil.append(sb, "<html><title>Show droplist page ", page, "</title><body><center><font color=\"LEVEL\">", npcData.getName(), " (", ")</font></center><br>");
		
		if (!npcData.getDropData().isEmpty())
		{
			sb.append("Drop type legend: <font color=\"3BB9FF\">Drop</font><br><table><tr><td width=20>item</td><td width=20>drop count</td></tr>");
			
			int myPage = 1;
			int i = 0;
			int shown = 0;
			boolean hasMore = false;
			
			for (DropCategory cat : npcData.getDropData())
			{
				if (shown == PAGE_LIMIT)
				{
					hasMore = true;
					break;
				}
				
				for (DropData drop : cat.getAllDrops())
				{
					if (myPage != page)
					{
						i++;
						if (i == PAGE_LIMIT)
						{
							myPage++;
							i = 0;
						}
						continue;
					}
					
					if (shown == PAGE_LIMIT)
					{
						hasMore = true;
						break;
					}
					
					StringUtil.append(sb, "<font color=\\\"3BB9FF\\\"><tr><td>", ItemTable.getInstance().getTemplate(drop.getItemId()).getName(), " (", drop.getMinDrop(), " - ", drop.getMaxDrop(), ")</td></tr></font>");
					shown++;
				}
			}
			
			sb.append("</table><table width=\"100%\" bgcolor=666666><tr>");
			
			if (page > 1)
			{
				StringUtil.append(sb, "<td width=120><a action=\"bypass -h voiced_show_droplist ", npcId, " ", page - 1, "\">Prev Page</a></td>");
				if (!hasMore)
					StringUtil.append(sb, "<td width=100>Page", page, "</td><td width=70></td></tr>");
			}
			
			if (hasMore)
			{
				if (page <= 1)
					sb.append("<td width=120></td>");
				
				StringUtil.append(sb, "<td width=100>Page ", page, "</td><td width=70><a action=\"bypass -h voiced_show_droplist ", npcId, " ", page + 1, "\">Next Page</a></td></tr>");
			}
			sb.append("</table>");
		}
		else
			sb.append("This NPC has no drops.");
		
		sb.append("</body></html>");
		
		final NpcHtmlMessage html = new NpcHtmlMessage(0);
		html.setHtml(sb.toString());
		activeChar.sendPacket(html);
	}
	
	@Override
	public String[] getVoicedCommandList()
	{
		return _voicedCommands;
	}
}

 

Edited by ThelwHelpRePaidia

6 answers to this question

Recommended Posts

  • 1
Posted
2 hours ago, Nightw0lf said:

bad aproach

But, but.. Having a voiced command to do exactly what shift click does is cool, UNIQUE feature :D

 

Ok, you can keep the voiced command if you wish, just link it to showDrop of shift click. There is no reason to reuse (copy, paste) the code.

  • 0
Posted (edited)

i tried to edit the npc.java but it didnt worked that's why i made voice command but it doesnt work this too im getting this error  http://prntscr.com/i6grqu   

 

 

 

Edited by ThelwHelpRePaidia
  • 0
Posted

i cant use code button dk why

<code>

        
        if (Config.ALT_GAME_VIEWNPC)
        {
            final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
            html.setFile("data/html/custom/mobinfo.htm");
            
            html.replace("%class%", getClass().getSimpleName());
            html.replace("%id%", getTemplate().getNpcId());
            html.replace("%lvl%", getTemplate().getLevel());
            html.replace("%name%", getTemplate().getName());
            html.replace("%race%", getTemplate().getRace().toString());
            html.replace("%tmplid%", getTemplate().getIdTemplate());
            html.replace("%castle%", (getCastle() != null) ? getCastle().getName() : "none");
            html.replace("%aggro%", (this instanceof Attackable) ? ((Attackable) this).getTemplate().getAggroRange() : 0);
            html.replace("%corpse%", getTemplate().getCorpseTime());
            html.replace("%enchant%", getTemplate().getEnchantEffect());
            html.replace("%hp%", (int) getCurrentHp());
            html.replace("%hpmax%", getMaxHp());
            html.replace("%mp%", (int) getCurrentMp());
            html.replace("%mpmax%", getMaxMp());
            
            html.replace("%patk%", getPAtk(null));
            html.replace("%matk%", getMAtk(null, null));
            html.replace("%pdef%", getPDef(null));
            html.replace("%mdef%", getMDef(null, null));
            html.replace("%accu%", getAccuracy());
            html.replace("%evas%", getEvasionRate(null));
            html.replace("%crit%", getCriticalHit(null, null));
            html.replace("%rspd%", getMoveSpeed());
            html.replace("%aspd%", getPAtkSpd());
            html.replace("%cspd%", getMAtkSpd());
            html.replace("%str%", getSTR());
            html.replace("%dex%", getDEX());
            html.replace("%con%", getCON());
            html.replace("%int%", getINT());
            html.replace("%wit%", getWIT());
            html.replace("%men%", getMEN());
            html.replace("%loc%", getX() + " " + getY() + " " + getZ());
            html.replace("%dist%", (int) Math.sqrt(player.getDistanceSq(this)));
            
            html.replace("%ele_dfire%", getDefenseElementValue((byte) 2));
            html.replace("%ele_dwater%", getDefenseElementValue((byte) 3));
            html.replace("%ele_dwind%", getDefenseElementValue((byte) 1));
            html.replace("%ele_dearth%", getDefenseElementValue((byte) 4));
            html.replace("%ele_dholy%", getDefenseElementValue((byte) 5));
            html.replace("%ele_ddark%", getDefenseElementValue((byte) 6));
            
            for (final DropCategory cat : getTemplate().getDropData())
            {
            final FastList<DropData> drops = (FastList<DropData>) cat.getAllDrops();
            if (drops != null)
                for (final DropData drop : drops)
                {
                    if (drop == null || ItemTable.getInstance().getTemplate(drop.getItemId()) == null || drop.getItemId() == 57 || drop.getItemId() == 5575)
                    {
                        continue;
                    }
                    
                    String name = ItemTable.getInstance().getTemplate(drop.getItemId()).getName();
                    int countmin = ItemTable.getInstance().getTemplate(drop.getMinDrop()).getItemId();
                    int countmax = ItemTable.getInstance().getTemplate(drop.getMaxDrop()).getItemId();
                    
                    if (drop.getChance() > 700000)
                    {
                        html.replace("<tr><td align=\"center\"><font color=\"0066FF\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                    else if (drop.getChance() > 500000)
                    {
                        html.replace("<tr><td align=\"center\"><font color=\"FF99FF\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                    else if (drop.getChance() > 300000)
                    {
                            html.replace("<tr><td align=\"center\"><font color=\"LEVEL\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                    else if (drop.getChance() > 100000)
                    {
                        html.replace("<tr><td align=\"center\"><font color=\"666666\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                    else if (drop.getChance() > 10000)
                    {
                        html.replace("<tr><td align=\"center\"><font color=\"FF8C00\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                    else
                    {
                        html.replace("<tr><td align=\"center\"><font color=\"FF0000\">" + countmin + "-"+countmax+"&nbsp;"+name+"</font></td></tr>");
                    }
                }
            }

 

 

</code>

  • 0
Posted

Don't use any of your crappy code. Simply find place where shift click is displayed. There is a check if (player.isGM()) { display htm } and add else { copy the content of previous and remove useless rows which you dont want to display, yet, you will have to care about the bypass - RequestBypassToServer - as far as I rem }.

Guest
This topic is now closed to further replies.


  • Posts

    • @Seamless  find this guy , is the best guy that u can find , plus is ULTRA trusted , rare to find trusted in maxcheaters
    • Looking for someone to setup a website for me with account panel and donate panel, I require to explain me how to setup the account panel to be working with player's emails and my lineage2 server and donate panel in order to be working with my paypal and my lineage2 server. Contact me here in forum, I will pick the best offert. Thank you.
    • TILL START - LEFT 3 DAYS ! GRAND OPENING FROM - 12/052025, FRIDAY, 20:00 +3 GMT !
    • SOCNET — BIRTHDAY! Thank you for staying with us! A week of maximum gifts, bonuses, and discounts! Today we celebrate the SOCNET project’s birthday — and YOU get the gifts! We’ve prepared powerful promotions across all our services: ⭐ SOCNET STORE — SHOP (website/telegram) 1. Promo code BIRTHDAY — 20% discount Use it for any product purchase! 2. Gift for a large purchase Spend $200 on any products and choose any item up to $10 — for free! 3. Gift balance for a comment in our store threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐ SOCNET SMM PANEL 1. Top-up = bonus Top up your balance by $100 and get +$5 to your balance. After topping up — create a ticket in the panel. 2. Gift balance for a comment in our SMM Panel threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET STARS — BOT FOR BUYING TELEGRAM STARS/PREMIUM 1. Large purchase = huge bonus Buy >1000 Stars in one transaction and get +100 Stars as a gift! After purchase, write to support. 2. Gift balance for a comment in our bot threads for star purchases "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. Leave a comment: ➡ 1 forum = +50 Stars to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET SMS SERVICE OF VIRTUAL NUMBERS 1. Top-up with bonus Top up your balance by $50 and get +$10 as a gift. After topping up — simply write to support. 2. Gift balance for a comment in our SMS service threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. Let’s celebrate together! Promotions are valid from 02.12.2025 to 07.12.2025 inclusive. Don’t miss it — these are the best conditions of the year! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • SOCNET — BIRTHDAY! Thank you for staying with us! A week of maximum gifts, bonuses, and discounts! Today we celebrate the SOCNET project’s birthday — and YOU get the gifts! We’ve prepared powerful promotions across all our services: ⭐ SOCNET STORE — SHOP (website/telegram) 1. Promo code BIRTHDAY — 20% discount Use it for any product purchase! 2. Gift for a large purchase Spend $200 on any products and choose any item up to $10 — for free! 3. Gift balance for a comment in our store threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐ SOCNET SMM PANEL 1. Top-up = bonus Top up your balance by $100 and get +$5 to your balance. After topping up — create a ticket in the panel. 2. Gift balance for a comment in our SMM Panel threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET STARS — BOT FOR BUYING TELEGRAM STARS/PREMIUM 1. Large purchase = huge bonus Buy >1000 Stars in one transaction and get +100 Stars as a gift! After purchase, write to support. 2. Gift balance for a comment in our bot threads for star purchases "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. Leave a comment: ➡ 1 forum = +50 Stars to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. ⭐SOCNET SMS SERVICE OF VIRTUAL NUMBERS 1. Top-up with bonus Top up your balance by $50 and get +$10 as a gift. After topping up — simply write to support. 2. Gift balance for a comment in our SMS service threads "Happy Birthday, SOCNET. My username/email is": BHW, BFD, voided, nulled, and patched forums. ➡ 1 forum = $1 to your balance! Send screenshots of your posts to support through the listed contacts, include your login/email, and receive the bonus on your account. Let’s celebrate together! Promotions are valid from 02.12.2025 to 07.12.2025 inclusive. Don’t miss it — these are the best conditions of the year! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts & Support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock