Jump to content

Recommended Posts

Posted

Hello, I am adapting it to acis 401, and when I run it in the game it tells me:

No rights defined for admin command 'admin_search'.
Admin tried to use admin command 'admin_search', but has no access to use it.

 

Also try to adapt it in AdminAdmin.java with else in the last lines using it as admin_buscar (buscar = search in spanish)
and I get the same error:
No rights defined for admin command 'admin_buscar'.
Admin tried to use admin command 'admin_search', but has no access to use it.


I have the AdminSearch.java like this:

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

import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

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

import net.sf.l2j.gameserver.data.xml.ItemData;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.WorldObject;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.item.kind.Item;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

public class AdminSearch implements IAdminCommandHandler
{
	private static final String[] ADMIN_COMMANDS =
	{
		"admin_search"
	};
	private static final int PAGE_LIMIT = 15;
	
	@Override
	public void useAdminCommand(String command, Player activeChar)
	{
		if (command.startsWith("admin_search"))
		{
			StringTokenizer st = new StringTokenizer(command, " ");
			st.nextToken();
			
			if (!st.hasMoreTokens())
			{
				final NpcHtmlMessage html = new NpcHtmlMessage(0);
				html.setFile("data/html/admin/search.htm");
				html.replace("%items%", "");
				html.replace("%pages%", "");
				activeChar.sendPacket(html);
				
			}
			else
			{
				final String item = st.nextToken();
				int page = 1;
				if (st.hasMoreTokens())
				{
					
					try
					{
						page = Integer.parseInt(st.nextToken());
					}
					catch (NumberFormatException e)
					{
						page = 1;
					}
				}
				results(activeChar, item, page);
			}
		}
		return;
	}
	
	private static void results(Player activeChar, String item, int page)
	{
		final NpcHtmlMessage html = new NpcHtmlMessage(0);
		html.setFile("data/html/admin/search.htm");
		
		//List<Item> items = new ArrayList<>();//no sirvio
		List<Object> items = Arrays.asList(ItemData.getInstance().getAllItems());
		
		for (Object itemName : items)
			if (itemName != null)
				if (((WorldObject) itemName).getName().toLowerCase().contains(item.toLowerCase()))
					items.add(itemName);
				
		if (items.isEmpty())
		{
			html.replace("%items%", "<tr><td>No items found with word " + item + ".</td></tr>");
			html.replace("%pages%", "");
			activeChar.sendPacket(html);
			return;
		}
		
		final int max = Math.min(100, MathUtil.countPagesNumber(items.size(), PAGE_LIMIT));
		items = items.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, items.size()));
		
		final StringBuilder sb = new StringBuilder();
		
		for (Object itemName : items)
		{
			String actualName = getFontedWord(item, ((WorldObject) itemName).getName());
			StringUtil.append(sb, "<tr><td>", actualName, " (", ((Item) itemName).getItemId(), ")", "</td></tr>");
		}
		html.replace("%items%", sb.toString());
		
		sb.setLength(0);
		
		for (int i = 0; i < max; i++)
		{
			final int pagenr = i + 1;
			if (page == pagenr)
				StringUtil.append(sb, pagenr, "&nbsp;");
			else
				StringUtil.append(sb, "<a action=\"bypass -h admin_search ", item, " ", pagenr, "\">", pagenr, "</a>&nbsp;");
			
		}
		
		html.replace("%pages%", sb.toString());
		activeChar.sendPacket(html);
	}
	
	private static String getFontedWord(String word, String tt)
	{
		
		int position = tt.toLowerCase().indexOf(word.toLowerCase());
		StringBuilder str = new StringBuilder(tt);
		
		String font = "<FONT COLOR=\"LEVEL\">";
		str.insert(position, font);
		str.insert(position + (font.length() + word.length()), "</FONT>");
		
		return str.toString();
	}
	
	@Override
	public String[] getAdminCommandList()
	{
		return ADMIN_COMMANDS;
	}
}

Can someone give me a hand and tell me what I'm doing wrong?

 

Posted
On 4/30/2024 at 2:57 AM, luzzifer said:

Hello, I am adapting it to acis 401, and when I run it in the game it tells me:

No rights defined for admin command 'admin_search'.
Admin tried to use admin command 'admin_search', but has no access to use it.

 

Also try to adapt it in AdminAdmin.java with else in the last lines using it as admin_buscar (buscar = search in spanish)
and I get the same error:
No rights defined for admin command 'admin_buscar'.
Admin tried to use admin command 'admin_search', but has no access to use it.


I have the AdminSearch.java like this:

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

import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

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

import net.sf.l2j.gameserver.data.xml.ItemData;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.WorldObject;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.model.item.kind.Item;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;

public class AdminSearch implements IAdminCommandHandler
{
	private static final String[] ADMIN_COMMANDS =
	{
		"admin_search"
	};
	private static final int PAGE_LIMIT = 15;
	
	@Override
	public void useAdminCommand(String command, Player activeChar)
	{
		if (command.startsWith("admin_search"))
		{
			StringTokenizer st = new StringTokenizer(command, " ");
			st.nextToken();
			
			if (!st.hasMoreTokens())
			{
				final NpcHtmlMessage html = new NpcHtmlMessage(0);
				html.setFile("data/html/admin/search.htm");
				html.replace("%items%", "");
				html.replace("%pages%", "");
				activeChar.sendPacket(html);
				
			}
			else
			{
				final String item = st.nextToken();
				int page = 1;
				if (st.hasMoreTokens())
				{
					
					try
					{
						page = Integer.parseInt(st.nextToken());
					}
					catch (NumberFormatException e)
					{
						page = 1;
					}
				}
				results(activeChar, item, page);
			}
		}
		return;
	}
	
	private static void results(Player activeChar, String item, int page)
	{
		final NpcHtmlMessage html = new NpcHtmlMessage(0);
		html.setFile("data/html/admin/search.htm");
		
		//List<Item> items = new ArrayList<>();//no sirvio
		List<Object> items = Arrays.asList(ItemData.getInstance().getAllItems());
		
		for (Object itemName : items)
			if (itemName != null)
				if (((WorldObject) itemName).getName().toLowerCase().contains(item.toLowerCase()))
					items.add(itemName);
				
		if (items.isEmpty())
		{
			html.replace("%items%", "<tr><td>No items found with word " + item + ".</td></tr>");
			html.replace("%pages%", "");
			activeChar.sendPacket(html);
			return;
		}
		
		final int max = Math.min(100, MathUtil.countPagesNumber(items.size(), PAGE_LIMIT));
		items = items.subList((page - 1) * PAGE_LIMIT, Math.min(page * PAGE_LIMIT, items.size()));
		
		final StringBuilder sb = new StringBuilder();
		
		for (Object itemName : items)
		{
			String actualName = getFontedWord(item, ((WorldObject) itemName).getName());
			StringUtil.append(sb, "<tr><td>", actualName, " (", ((Item) itemName).getItemId(), ")", "</td></tr>");
		}
		html.replace("%items%", sb.toString());
		
		sb.setLength(0);
		
		for (int i = 0; i < max; i++)
		{
			final int pagenr = i + 1;
			if (page == pagenr)
				StringUtil.append(sb, pagenr, "&nbsp;");
			else
				StringUtil.append(sb, "<a action=\"bypass -h admin_search ", item, " ", pagenr, "\">", pagenr, "</a>&nbsp;");
			
		}
		
		html.replace("%pages%", sb.toString());
		activeChar.sendPacket(html);
	}
	
	private static String getFontedWord(String word, String tt)
	{
		
		int position = tt.toLowerCase().indexOf(word.toLowerCase());
		StringBuilder str = new StringBuilder(tt);
		
		String font = "<FONT COLOR=\"LEVEL\">";
		str.insert(position, font);
		str.insert(position + (font.length() + word.length()), "</FONT>");
		
		return str.toString();
	}
	
	@Override
	public String[] getAdminCommandList()
	{
		return ADMIN_COMMANDS;
	}
}

Can someone give me a hand and tell me what I'm doing wrong?

 

add <aCar name="admin_search" accessLevel="7" params="" desc=""/> to data/xml/adminCommands

  • Like 1
Posted
As a sidenote, it was added in aCis 408, under //find subcategory :

AdminCommands
- Revamp //tele panels.
- Introduce //find item [name]. Ty melron for initial idea, StinkyMadness/CUCU23 for improvements.
- Introduce //find npc [name], delete 6 related admincommands :
- admin_show_spawns
- admin_spawn_index
- admin_spawn_reload
- admin_npc_index
- admin_spawn_once
- admin_show_npcs

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.




  • Posts

    • Hello, I'm working with custom Icons and noticed that you can use 64x64 icons and the client will handle them without problems in the Inventory and when you Drag them, they look HD so it's really cool, the problem starts when you move them to the shortcut bar, when they're placed there instead of rescaling the icon it just show the upper left corner (so it's 32x32 but showing only the part that fits in that space). I tried checking interface.u but can't find the line where the size for the icons in the shortcut bar are handled.   When in Inventory the item shows in a 32x32 size, if I use a 64x64 icon it re-scales so the icon looks great When dragging the item the image becomes 64x64 which looks pretty big, but it works good When placing the item in the shortcut bar only the top left of the icon is visible   Is there a way I can adjust the shortcut bar so that it re-scales the icon?
    • If you want to edit a large amount of entries in the L2 File-edit I recommend using excel, since both work with columns you can copy the entire file or just a few lines and paste it in excel and it will copy without problems, after you're done with editing you just select the cells and paste them in the .dat file making sure you're formatting correctly. I'm currently doing a massive edit on all gear and that's how i'm handling the .dat work
    • the logic is the "stacking" that is a filter if you use it then the item cannot co-exist (stack)
    • [Exclusive L2Gold Weekend Server] Available ONLY on Saturdays & Sundays – nowhere else, no other time ! Custom Armors (Dynasty, Apella) Custom Weapons (L2Gold Weapons) Custom Jewelry (L2Gold Jewelry) Custom Teleport System Custom AIO Buffer Custom Zones & NPCs Custom Raidboss … and much more waiting for you every weekend! This is not just another private server – it’s a limited-time battleground. When the weekend comes, everyone gathers in one place for the ultimate L2 experience. 👉 Online: Saturday–Sunday only 👉 Contact / Info: [https://www.facebook.com/profile.php?id=61578869175323]
    • ⏳ The price drops like sand slipping down in an hourglass.   📉 USA numbers are already at the lowest 💸 🌍 Next in line: Europe, Asia, and dozens of other countries.     All next week we’ll be actively working on lowering prices. The process has already started  soon costs will be much cheaper. 🔥 Get ready: the price drop will affect every country!   Website link — https://vibe-sms.net/ Our Telegram channel — https://t.me/vibe_sms
  • 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