[HELP] item check issue
Posted: Mon Jun 28, 2010 8:56 pm
L2J Revision n/a:
L2JDP Revision n/a:
Hi again,
Let's say I have such part of code, where I'm checking for an item DEFINED in config file:
Is it possible to check for player's item names without "looking" into his inventory? (I won't even try -> an obvious nullpointer will appear IMHO)
I can get that item name from DB, but the questions are:
1. Is it effective?
2. How to pull out a single string from DB, let's say I have a custom method like this:
If I'm doing it completely wrong please give me a hint how to catch up with it.
Thx in advance
Tom
P.S. If my topic doesn't fit into this venue, pls move it (I need to earn the rights to post in Custom Section) Sorry and Thank You!
L2JDP Revision n/a:
Hi again,
Let's say I have such part of code, where I'm checking for an item DEFINED in config file:
Code: Select all
if(player.getInventory().getItemByItemId(Config.NEEDED_ITEM) == null) {player.sendMessage("You run out of " + //and bump... ); return;}
I can get that item name from DB, but the questions are:
1. Is it effective?
2. How to pull out a single string from DB, let's say I have a custom method like this:
Code: Select all
public final String GetItemNameFromDB(){ String itemName = new String(); try { Connection conn = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = conn.prepareStatement("SELECT name FROM etcitem WHERE item_id = " + Config.NEEDED_ITEM); ResultSet rset = statement.executeQuery(); itemName = //... now, how to get that string? conn.close(); statement.close(); } catch(SQLException e) { e.printStackTrace(); } return itemName;}
Thx in advance
Tom
P.S. If my topic doesn't fit into this venue, pls move it (I need to earn the rights to post in Custom Section) Sorry and Thank You!