Jump to content
  • 0

Question

Posted (edited)

Hi, I'm trying to create a npc for augment but it's not showing the items the player has in inventory what do I do?

 

error should be here


 Set<ItemInstance> invitems = player.getInventory().getItems();

 

is not listing inventory items


        

Edited by l2jkain

12 answers to this question

Recommended Posts

  • 0
Posted
8 minutes ago, Devlin said:

para (ItemInstance i: invites)

       i.blabla ();

 

É assim que você chama os itens?

yes 

 

Good, I'll try this way.


final Set <ItemInstance> invitems;

invitems = player.getInventory (). getItems ();

  • 0
Posted (edited)

No reasons it wouldn't work. That would mean all calls would fail also, notably your own player inventory (using tab button, should show nothing), GM packet to show inventories of other players, etc.

 

If it's empty, it means you didn't load the data. Log the content or the size of the _items, it's probably not empty. I guess your use of the content is wrong.

Edited by Tryskell
  • 0
Posted
11 hours ago, Tryskell said:

No reasons it wouldn't work. That would mean all calls would fail also, notably your own player inventory (using tab button, should show nothing), GM packet to show inventories of other players, etc.

 

If it's empty, it means you didn't load the data. Log the content or the size of the _items, it's probably not empty. I guess your use of the content is wrong.

 

Is not verification right?

 


/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package net.sf.l2j.gameserver.model.actor.instance;

import java.util.StringTokenizer;

import net.sf.l2j.commons.random.Rnd;
import net.sf.l2j.gameserver.ai.CtrlIntention;
import net.sf.l2j.gameserver.datatables.AugmentationData;
import net.sf.l2j.gameserver.model.L2Augmentation;
import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.item.kind.Weapon;
import net.sf.l2j.gameserver.model.item.type.CrystalType;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage.SMPOS;
import net.sf.l2j.gameserver.network.serverpackets.ExVariationCancelResult;
import net.sf.l2j.gameserver.network.serverpackets.ExVariationResult;
import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.network.serverpackets.SkillList;
import net.sf.l2j.gameserver.network.serverpackets.SocialAction;
import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;

public final class FastAug extends Folk
{

    public FastAug(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }
    
    @Override
    public void onBypassFeedback(Player player, String command)
    {
        if(player==null)
            return;
        
        final StringTokenizer st = new StringTokenizer(command, " ");
        final String currentcommand = st.nextToken();
            
        final String letsSliptIt = currentcommand;
        final String[] nowTheId = letsSliptIt.split("-");
        
        final String OurSplititCommand = nowTheId[0];
        final String FinallyWeHaveObjectId = nowTheId[1];
        
        switch (OurSplititCommand)
        {
            case "showremlist":
                showListWindowForRemove(player);
                player.sendPacket(new ActionFailed());
                break;
            case "showauglist":
                showListWindow(player);
                player.sendPacket(new ActionFailed());
                break;
            case "tryremove":
                
                final ItemInstance itemToRem = player.getInventory().getItemByObjectId(Integer.parseInt(FinallyWeHaveObjectId));
                  
                 if(itemToRem == null )
                 {
                     player.sendPacket(new ActionFailed());
                     return;
                 }
                 
                if (itemToRem.isEquipped())
                {
                    player.disarmWeapons();
                    player.broadcastUserInfo();
                }

                itemToRem.removeAugmentation();
                
                player.sendPacket(new ExVariationCancelResult(1));

                InventoryUpdate iu = new InventoryUpdate();
                iu.addModifiedItem(itemToRem);
                player.sendPacket(iu);
                
                player.sendPacket(new SkillList());
                
                SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.AUGMENTATION_HAS_BEEN_SUCCESSFULLY_REMOVED_FROM_YOUR_S1);
                sm.addItemName(itemToRem);
                player.sendPacket(sm);
                showListWindowForRemove(player);
                player.sendPacket(new ActionFailed());
                break;
                
            case "tryaug":
                if (player.getInventory().getInventoryItemCount(57, 0) < 200000)
                 {
                    player.sendMessage("You do not have enough adena!");
                    player.sendPacket(new ActionFailed());
                    return;
                 }
            
                 final ItemInstance itemToAug = player.getInventory().getItemByObjectId(Integer.parseInt(FinallyWeHaveObjectId));
                 
             
                 if(itemToAug == null )
                 {
                     player.sendPacket(new ActionFailed());
                     return;
                 }
                 
                if (itemToAug.isEquipped())
                {
                    player.disarmWeapons();
                    player.broadcastUserInfo();
                }
                
                 final L2Augmentation aug = AugmentationData.getInstance().generateRandomAugmentation(2,2);
                 itemToAug.setAugmentation(aug);
                                           
                final int stat12 = 0x0000FFFF & aug.getAugmentationId();
                final int stat34 = aug.getAugmentationId() >> 16;
                player.sendPacket(new ExVariationResult(stat12, stat34, 1));
                
                InventoryUpdate iua = new InventoryUpdate();
                iua.addModifiedItem(itemToAug);
                player.sendPacket(iua);
                
                StatusUpdate su = new StatusUpdate(player);
                su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
                player.sendPacket(su);
                
                showListWindow(player);
                
                player.getInventory().reduceAdena("FastAugh", 200000, player, null);

                player.sendPacket(SystemMessageId.THE_ITEM_WAS_SUCCESSFULLY_AUGMENTED);
                
                if(itemToAug.getAugmentation().getSkill()!=null)
                {
                   player.sendPacket(new ExShowScreenMessage("You have " + itemToAug.getAugmentation().getSkill().getName(), 5000, SMPOS.TOP_CENTER, true));
                   player.sendPacket(new SkillList());
                }

                player.sendPacket(new ActionFailed());
                break;    
            default: // Send a Server->Client packet ActionFailed to the Player
                player.sendPacket(new ActionFailed());
                return;
        }
        
        super.onBypassFeedback(player, command);
        
        player.sendPacket(new ActionFailed());
    }
    
    public void showListWindow(Player player)
    {
        NpcHtmlMessage nhm = new NpcHtmlMessage(5);
        StringBuilder tb = new StringBuilder("");
        String Rem = "RemoveAug";
        
        tb.append("<html><head><title>L2-Kamui</title></head><body>");
        tb.append("<center>");
        tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
        tb.append("<tr>");
        tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
        tb.append("<td valign=\"top\"><font color=\"FF6600\">AugmentHelper</font>");
        tb.append("<br1><font color=\"00FF00ju\">" + player.getName() + "</font>, use this menu for fast augment :)<br1></td>");
        tb.append("</tr>");
        tb.append("</table>");
        tb.append("</center>");
        tb.append("<center>");
        tb.append("<br>");
                
        for (ItemInstance item : player.getInventory().getItems())
        {       
            if(item==null)
                continue;

            boolean canBeShow = isValid(player, item);
            
            if(canBeShow)
             {
                tb.append("<button value=\""+item.getItemName()+"\" action=\"bypass -h npc_" + getObjectId() + "_tryaug-"+item.getObjectId()+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
             }                  
        }
        
        tb.append("<br>");
        tb.append("<button value=\""+Rem+"\" action=\"bypass -h npc_" + getObjectId() + "_showremlist-1"+"\" width=204 height=20 back=\"sek.cbui75\" fore=\"sek.cbui75\"><br>");
        tb.append("</center>");
        tb.append("</body></html>

  • 0
Posted (edited)
  • First, unhardcode HTM - that's as much String cached you don't need to create on every call.
  • Second, use StringUtil.append, notably on the for loop.
  • Third, isValid() content is probably wrong. And item can't be null, by the way.

Replace

        for (ItemInstance item : player.getInventory().getItems())
        {       
            if(item==null)
                continue;

For

for (ItemInstance item : player.getInventory().getItems())
{       
      System.out.println(item.getItem().getName());

If you got inventory content on console, then the problem comes from your isValid() method which probably returns false everytime.

Edited by Tryskell
  • 0
Posted

Sometimes i feel like people dont know how to use prints properly.

The first thing i do is to create a print function (e.g C ) and get addresses and values...

Also,ur xmass gift should be this https://images-na.ssl-images-amazon.com/images/I/518VZN07C1L._SX400_BO1,204,203,200_.jpg 

  • 0
Posted
5 hours ago, bravetobe said:

Sometimes i feel like people dont know how to use prints properly.

The first thing i do is to create a print function (e.g C ) and get addresses and values...

Also,ur xmass gift should be this https://images-na.ssl-images-amazon.com/images/I/518VZN07C1L._SX400_BO1,204,203,200_.jpg 

 

It's a temporary log to see if it works or not. It hasn't any point to be kept as it is. It's totally pointless to speak about if it works fine, if there are better ways to write it, or whatever. You could at least "attack" me on the fact I don't say the dude to use debug tool, but crafting your own debug print is ridiculous too.

 

Please, avoid to "teach me" things when you do things bad yourself.

 

I invite you to read the book you linked, if there is a Eclipse debug tool chapter.

  • 0
Posted (edited)
2 hours ago, Tryskell said:

 

It's a temporary log to see if it works or not. It hasn't any point to be kept as it is. It's totally pointless to speak about if it works fine, if there are better ways to write it, or whatever. You could at least "attack" me on the fact I don't say the dude to use debug tool, but crafting your own debug print is ridiculous too.

 

Please, avoid to "teach me" things when you do things bad yourself.

 

I invite you to read the book you linked, if there is a Eclipse debug tool chapter.

u misunderstood my post.it has nothing to do with ur code/post.

People (like op) come up with questions when they dont use a single print in a 120+ lines of code.(btw rofl)

 

Its not my job to teach anyone online what to do.Besides,questioning its way safer than telling "u are wrong" and u know that better than i do.Also i said that i do it myself and i said "the first thing i do is to create a print function .." when thats what u do is printing....Why did u get that as "u are wrong" LOL

Btw,i showed my book Kappa.

 

Btw about "crafting ur own debug print is ridiculous"  what does it even mean?

Can u explain why this is ridiculous?

If u have any better ways to check if values are correct,then go on.

Wow...

void showTable(Pair_t *P) {
	int i;
	printf("============================= \n");
	for (i = 0; i < size; i++) {
		printf("X: %d    %p , Y: %d    %p \n", P[i].x, &(P[i].x), P[i].y, &(P[i].y));
	}
	printf("============================= \n");
}

 

Edited by bravetobe
  • 0
Posted
55 minutes ago, bravetobe said:

u misunderstood my post.it has nothing to do with ur code/post.

People (like op) come up with questions when they dont use a single print in a 120+ lines of code.(btw rofl)

 

Its not my job to teach anyone online what to do.Besides,questioning its way safer than telling "u are wrong" and u know that better than i do.Also i said that i do it myself and i said "the first thing i do is to create a print function .." when thats what u do is printing....Why did u get that as "u are wrong" LOL

Btw,i showed my book Kappa.

 

Btw about "crafting ur own debug print is ridiculous"  what does it even mean?

Can u explain why this is ridiculous?

If u have any better ways to check if values are correct,then go on.

Wow...


void showTable(Pair_t *P) {
	int i;
	printf("============================= \n");
	for (i = 0; i < size; i++) {
		printf("X: %d    %p , Y: %d    %p \n", P[i].x, &(P[i].x), P[i].y, &(P[i].y));
	}
	printf("============================= \n");
}

 

 

You don't need to log anything when you know what you code. The debug stuff hasn't any uses once the functionality is done (and works). I almost never log things when I rework / fully code stuff. If you comment and build your code correctly, it's not needed.

 

Your printf is unreadable (at least for my java knowledge), you wouldn't get worst if you were obfuscating it. If you're on a team, and someone codes things like that, you need to get a documentation to understand it.

 

Debug tool is used to see if values are correct, you can even edit them on the fly to see results. Logging as debug is for lazy asses (or if you didn't activate debug tool).

 

So coding formatting print functions is a waste of time, at least for debug purposes (which was the whole point).

  • 0
Posted (edited)
1 hour ago, Tryskell said:

 

You don't need to log anything when you know what you code. The debug stuff hasn't any uses once the functionality is done (and works). I almost never log things when I rework / fully code stuff. If you comment and build your code correctly, it's not needed.

 

Your printf is unreadable (at least for my java knowledge), you wouldn't get worst if you were obfuscating it. If you're on a team, and someone codes things like that, you need to get a documentation to understand it.

 

Debug tool is used to see if values are correct, you can even edit them on the fly to see results. Logging as debug is for lazy asses (or if you didn't activate debug tool).

 

So coding formatting print functions is a waste of time, at least for debug purposes (which was the whole point).

personally i dont think that like 7 lines of code + call is waste of time.

I would take all the way those 10 seconds and visually find in the first run whats wrong instead of searching in the code "whats wrong with that rigatoni"

 

Why exactly someone would need documentation to understand what this printTable does?First of all,the purpose wont exist once i m done with the code and secondly,if someone doesnt understand how that print works,he should throw his certificate into the trashbin.

"Ur printf is unreadable".... u wot m8.This is no different with what u did by urself and no different than showing the values/addr of an array.

If u ask me,i consider waste of time to use the debug tool when i can type 1 print and check the console.

Why would u use any debug tool for something like this when u can see even in the first run whats going on ... 

 

If i m on a team,there is no reason to keep any code that isnt included in the main project.That code is for "personal" usage until the code works as intented.

 

People tend to code with their own personal preferences.It would be way better for someone who isnt developer,to do this way and not like OP's.

Thats my point.I prefer people using prints and search before asking instead of writing 120+ lines of code in 1 method / function (omg just kill me if its C).

 

Besides,the prints are in the console and they have nothing to do with the project itself.Whats the point to keep them when u are done.

 

P.S Maybe i print stuff coz i hate asm who knows Kappa

And btw,i m looking forward to see how u will explain OP's 120ish code spree.I did that stuff in my first year... Btw he is (future) admin.Well played

Also,i forgot to mention that i was doing some OpenGL stuff and the coordinates of the mouseclicks were saved in the array and each time the mouseclick was close to one of the cords,then the closest one was changing (so the draw is changing so the lines were changing ,so the startpoints and the end points where changing).So if u ask me,yea i prefer to check visually that sht.

 

tl;dr ANYWAY ,that wall of text was unintended.Its not about whats wrong and whats correct.The point is OP needs that book and he should debug his code

Edited by bravetobe

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

    • Reconstructed the MSNP8 client/server chain in Lineage 2 (from C4 to HFp5) with full protocol capabilities + added Discord integration    Clean MSNP8:       MSNP8 + Discord Bridge:   
    • I'm looking for the GVE code for Luecera2.
    • Recommended seller, I'm using his services. Good luck @Ave
    • https://l2.gamedream.pl/ Update #2 — GameDream Interlude (C6)     This update focuses on Epic bosses, quest chains and overall QoL :cool Highlights: Frintezza access follows a full retail-like chain: Four Goblets → Last Imperial Prince → Journey to a Settlement Retail-like entry requirements restored (scroll + Command Channel) Four Goblets quest is now available in-game Shot visuals synced with attack/skill usage Community Board Premium Shop refreshed with classic Interlude buttons and cleaner tables Epic Raidboss access: Frintezza — 4–5 party Command Channel + scroll + Antique Brooch Antharas — Portal Stone Baium — Bloody Fabric Valakas — Floating Stone Queen Ant / Core / Orfen / Zaken — no quest gates Bug Fixes & QoL: Frintezza quest chain fully fixed TvT rewards — single reward + anti-abuse protection Shots — no double triggering Premium Shop — no blank tabs Mammon NPCs in Giran working correctly Cancel works retail-like (up to 5 buffs removed) Summon Friend fixed with anti-exploit guards YetiBuffer — Saved Buff Profiles (Save / Clear / Restore) PvE — increased aggro range + balance tweaks EXP toggle commands: expoff / expon / expblock Thanks for testing and feedback — more updates coming soon ❤️
    • Hello I would like to offer You my NEW 2026 Updater / Launcher with custom skins.   - UPDATER FEATURES -   1. Performance and Intelligent Resource Management: Smart Disk Detection (SSD/HDD): The updater automatically detects the user's drive type. For SSD/NVMe drives: Launches up to 8-12 concurrent threads, utilizing the full yet optimized connection speed. For HDD drives: Limits the thread count (to 2-3) to prevent computer slowdowns and avoid overloading the drive head. Multi-threaded Downloading: Instead of downloading file by file, the updater downloads multiple files simultaneously, drastically reducing update time. ZSTD Compression: Support for the modern Zstandard compression algorithm (.zst). Files are downloaded in compressed form and decompressed on the fly, saving bandwidth and accelerating downloads. HTTP/2 and Keep-Alive Support: Utilizing the HTTP/2 protocol and persistent connections allows for the instant download of thousands of small files without establishing a new connection for each one.   2. Modern User Interface (UI/UX): Transparency and PNG Graphics: Support for irregular window shapes, allowing for the creation of a unique, modern launcher look. Taskbar Integration: The progress bar is displayed not only in the window but also on the Windows taskbar icon. Built-in News Browser (Optional): The updater features a built-in browser module that displays news/changelogs directly within the launcher (without opening an external browser). Multi-language Support (Optional): Built-in language switching system (e.g., EN/PL/RU, etc.) with dynamic loading of button graphics and text. Animated Buttons (Optional): Dedicated, animated buttons redirecting to Discord, Facebook, YouTube, Instagram, and the website.   3. Technical Features and Application Security: Anti-Dual Run (Optional): The updater checks if the game is already running to prevent file conflicts during updates. Error Diagnostics: Built-in logging system (debug_log.txt) and hardware exception handling (SEH), facilitating the diagnosis of problems for players who cannot run the game. Internal Configuration: Updater settings are stored inside the .exe file, eliminating publicly accessible configuration files.   4. File Categorization (Normal vs. Critical vs. Once): Critical Files: Critical files are verified more thoroughly (via MD5 Hash) even in quick check mode to guarantee stability. Normal Files: Standard game files (textures, models, sounds) are checked depending on the selected mode (Quick vs. Full). Once Files (Overwrite Exclusions): Applies to user configuration files (e.g., Option.ini, User.ini).   5. Check Modes (Verification Algorithms): Self-Update: The updater can update itself before checking game files, allowing for easy deployment of launcher fixes. The updater supports two main operating modes that switch intelligently based on user action: Smart Check (Startup Quick Check): Runs automatically upon updater startup or pressing the START button (unless a full check is forced). Full Check (Full MD5 Verification): Manually triggered by the player via the "Full Check" button. Automatic Update Detection: If a newer version of a file appears on the server, it is automatically detected and downloaded without player interaction. Atomic Updates: Files are downloaded and verified first, and only then saved to the disk. This prevents game client corruption in case of internet connection loss. The entire process takes seconds, even with clients weighing 30GB+. - PATCH BUILDER FEATURES -   1. Professional File Structure Management (Tree-List Hybrid): Directory Tree Visualization: Instead of a flat file list, the Builder displays a clear structure of folders and subfolders. You can collapse and expand entire tree branches, facilitating work with thousands of files. Normal and Critical Division: A clear window division into two main zones: Normal Files and Critical Files. Ghost and Excluded Files Division: The interface visually informs about the status of unchanged files (existing in the previous patch version) and files excluded from the update. Show/Hide Ghosts: With one click, you can hide unchanged files to focus solely on what you are actually sending to players in this update.   2. Intuitive Interaction: Drag & Drop: Full Drag & Drop support. You can grab files or entire folders and drag them between the "Normal" and "Critical" lists. Transfer is intelligent – it moves the entire content of selected folders. Keyboard Shortcuts: Fast workflow thanks to keyboard support: Delete, Enter, Ctrl+A / Ctrl+C (select and copy paths).   3. Advanced Filtering and Searching: Context Search: The search bar works in real-time, filtering the file tree. Type /folder: Searches only within folder names. Type *ex: Shows only excluded files. Standard Typing: Searches files by name.   4. Automation and Security: Auto Self-Update: The Builder automatically detects the updater executable file. Real-Time Statistics: The status bar continuously shows the file count (Normal/Critical), total patch weight (in Bytes/MB/GB), and the last update date. System File Protection: Files marked as "Critical" cannot be accidentally added to the exclusion list – the program blocks such actions.   5. Performance (Backend): ZSTD Compression: The Builder uses the latest Zstandard algorithm to compress files before sending, ensuring a significantly smaller patch size than standard ZIP, saving server bandwidth and player time. Multi-threading: The packing and MD5 checksum generation process utilizes multiple CPU threads, drastically reducing patch building time.   - PRICING - NEW Updater standard price: 79 euro (if You ask for mods, price will change).   - CONTACT - Discord: ave7309   CLICK HERE TO CHECK LATEST TEMPLATES!                         * I have right to REFUSE to take an order. * Supported games: Lineage 2 / Black Desert / MU Online / Tantra / Rohan / Aion / Cabal / Fiesta any more...  
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..