Jump to content
  • 0

Items Store Under One Id


Question

Posted (edited)

Hello guys i'm looking for method that i would  be able to use one id with a few ids inside for example  if i put in droplist id 9999 it will  generate random item and will drop it . like  it wont be necessary to add the items one by one in the drop list ,  i have found a code for gracia final but when i tried to put it on interlude (acis) its not working its . In the database its saying  Droplist data for undefined itemId: 9999.  Also there is no error on the Gameserver----> its saying . Loaded 63 item lists from the database.

....and loaded 3 combined item lists from the database. I'm using  Acis 368 rev http://prntscr.com/fdluip thats the database 
package net.sf.l2j.gameserver.datatables;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;

import javolution.util.FastList;
import javolution.util.FastMap;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.commons.random.Rnd;

public class ItemLists
{
protected static final Logger _log = Logger.getLogger(ItemLists.class.getName());
private FastMap<String, FastList<Integer>> _itemLists;

public static ItemLists getInstance()
{
	return SingletonHolder._instance;
}

private ItemLists()
{
	loadLists();
}

public void loadLists()
{
	_itemLists = new FastMap<String, FastList<Integer>>();
	
	Connection con = null;
	try
	{
		con = L2DatabaseFactory.getInstance().getConnection();
		PreparedStatement statement = con.prepareStatement("SELECT * FROM itemlists");
		ResultSet result = statement.executeQuery();
		
		int count = 0;
		
		while (result.next())
		{
			String list = result.getString("list");
			if (list == null)
				continue;
			
			if (list.equalsIgnoreCase(""))
				list = "0";
			
			final StringTokenizer st = new StringTokenizer(list, ";");
			FastList<Integer> fastlist = new FastList<Integer>();
			
			while (st.hasMoreTokens())
			{
				int itemId = 0;
				
				try
				{
					itemId = Integer.parseInt(st.nextToken());
				}
				catch (Exception e)
				{
					e.printStackTrace();
					itemId = 0;
				}
				
				if (itemId != 0)
					fastlist.addLast(itemId);
			}
			
			final String name = result.getString("name");
			
			if (!_itemLists.containsKey(name))
			{
				_itemLists.put(name, fastlist);
				count++;
			}
		}
		
		result.close();
		statement.close();
		
		_log.config("Loaded " + count + " item lists from the database.");
		
		statement = con.prepareStatement("SELECT name, include FROM itemlists");
		result = statement.executeQuery();
		
		count = 0;
		
		while (result.next())
		{
			String include = result.getString("include");
			
			if (include == null || include.equalsIgnoreCase("0"))
				continue;
			
			final StringTokenizer st = new StringTokenizer(include, ";");
			FastList<Integer> fastlist = new FastList<Integer>();
			
			while (st.hasMoreTokens())
			{
				int listId = 0;
				
				try
				{
					listId = Integer.parseInt(st.nextToken());
				}
				catch (Exception e)
				{
					e.printStackTrace();
					listId = 0;
				}
				
				if (listId != 0)
				{
					fastlist.addAll(_itemLists.get(getListName(listId)));
				}
			}
			
			_itemLists.get(result.getString("name")).addAll(fastlist);
			count++;
		}
		
		_log.config("....and loaded " + count + " combined item lists from the database.");
	}
	catch (Exception e)
	{
		_log.log(Level.SEVERE, "Error loading item lists.", e);
	}
	finally
	{
		try
		{
			con.close();
		}
		catch (Exception e)
		{
		}
	}
}

public String getListName(int listId)
{
	int count = 1;
	
	if (listId > 1000000)
		listId -= 1000000;
	
	for (String val : _itemLists.keySet())
	{
		if (count == listId)
			return val;
		
		count++;
	}
	
	_log.warning("getListName() of ItemLists returned null!!!!!!!!!!!");
	return null;
}

public int generateRandomItemFromList(int listId)
{
	final String name = getListName(listId);
	
	if (name != null)
	{
		FastList<Integer> val = _itemLists.get(name);
		
		if (val != null && !val.isEmpty())
			return val.get(Rnd.get(val.size()));
	}
	
	_log.warning("generateRandomItemFromList() of ItemLists returned 0!!!!!!!!!!! list id: " + listId);
	return 0;
}

public FastList<Integer> getFirstListByItemId(int itemId)
{
	for (FastList<Integer> list : _itemLists.values())
	{
		if (list != null && list.size() > 0)
		{
			if (list.contains(itemId))
				return list;
		}
	}
	
	return null;
}

public void debug()
{
	System.out.println(_itemLists.toString());
}

@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final ItemLists _instance = new ItemLists();
}
}
Edited by BaM4yYy

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

Just add a check in drop method of your pack. make a list or with one while loop of the items you want and when the retail drop is under dropping just add your drop there.

 

example with a random item:

// Check if the autoLoot mode is active
if ((isRaid() && Config.AUTO_LOOT_RAID) || (!isRaid() && Config.AUTO_LOOT))
	player.doAutoLoot(this, item); // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
else
	dropItem(player, item); // drop the item on the ground

+	int itemId = Rnd.get(1,9000);
+	ItemInstance extraItem = ItemTable.getInstance().createItem("Extra Item", itemId, 1, player, null);
+	
+	while (extraItem == null)
+	{
+		itemId = Rnd.get(1,9000);
+		extraItem = ItemTable.getInstance().createItem("Extra Item", itemId, 1, player, null);
+	}
+	
+	IntIntHolder specialItem = new IntIntHolder(extraItem.getItemId(),1);
+	//finally
+	if (your config)
+		player.doAutoLoot(this, specialItem);
+	else
+		dropItem(player, specialItem);
Edited by melron
  • 0
Posted (edited)

Create a new DropData, feed it with infos (you can even use categories with this system), and apply it to all references (at server startup, or event startup). Keep references to clean them once the event is done, or don't keep references at all if you want them permanent.

 

That way you can control count of items based on numerous custom aspects (min/max, multiple categories, and stuff such as hp multiplier of monster, retrieving npc template skill hp multiplier, for example).

 

Your stuff is garbage, you should start it anew.

Edited by Tryskell

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! 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
    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! 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
    • NFT gifts on Telegram are already here! Buy Stars at SOCNET — the black background can be yours today! Purchase existing gifts in the official store using Telegram Stars, pay for subscriptions, donate to games and projects, pay for Premium, and react to messages in channels! Low prices, many payment methods, and other cool and unique features! Try it today — SOCNET STARS BOT Active links to SOCNET stores: Digital Goods Store (Website): Go Store Telegram Bot: Go – convenient access to the store via Telegram messenger. Telegram Bot for purchasing Telegram Stars: Go – fast and beneficial purchase of stars in Telegram. SMM Panel: Go – promotion of your social media accounts. We would like to present to you the current list of promotions and special offers for purchasing our products and services: 1. Promo code OCTOBER2025 (8% discount) for purchases in our store (Website, bot) in September! You can also use the first-purchase promo code: SOCNET (15% discount) 2. Get $1 credited to your store balance or a 10–20% discount — simply write your username after registration on our website in the following format: "SEND ME BONUS, MY USERNAME IS..." — you need to post it in our forum thread! 3. Get $1 for your first SMM Panel trial: just open a ticket titled “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our Stars purchasing bot! 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
    • Wts adena 1kk = 10$  discord - GODDARDSHOP 
    • Thanks for the feedback! We’ve actually rented their infrastructure to ensure a high-quality gaming experience (We couldn't find any better files out there). Developer @FixerRay will also be there to assist us 🙂
  • 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