Jump to content
  • 0

Admin command problem


Question

Posted (edited)

Im using this code (https://pastebin.com/MvUQ6NNv) to show player inventory and delete selected item.

it should have an [X] icon next to the item and  when clicked it would delete but it doesnt appear. also it lists all the items in 1 page and not in defferent pages. when i click on the page No. it just refreshes the command.. 

 

getting this error  when i mannually try the delete command :  

Exception during execution of admin_delete_item
java.lang.StringIndexOutOfBoundsException: begin 18, end 17, length 17

 

inventory.png.12dedded8b93b25931cd8abef476ee24.png

 

 

it should be like this:

779399164_invworking.png.eb056c5463898ebbd4609cc215c284e1.png

Edited by Drazeal

4 answers to this question

Recommended Posts

  • 0
Posted
26 minutes ago, Drazeal said:

Im using this code (https://pastebin.com/MvUQ6NNv) to show player inventory and delete selected item.

it should have an [X] icon next to the item and  when clicked it would delete but it doesnt appear. also it lists all the items in 1 page and not in defferent pages. when i click on the page No. it just refreshes the command.. 

 

getting this error  when i mannually try the delete command :  

Exception during execution of admin_delete_item
java.lang.StringIndexOutOfBoundsException: begin 18, end 17, length 17

 

Your problem is in this line: 

 

String val = command.substring(ADMIN_COMMANDS[1].length() + 1);

 

Java basically is trying to substring the current String using bigger length than the String's length.

The way it tries to retrieve the id of the selected item afterwards it's ancient so instead you can use

StringTokenizer.

 

The way to use it is the following: 

 

final StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // Unused since it's the admin's command

final int itemId = Integer.parseInt(st.nextToken());

 

Consider the code is written by hand. I just want to give you the idea.

 

  • 0
Posted (edited)
3 hours ago, Kara said:

 

Your problem is in this line: 

 




String val = command.substring(ADMIN_COMMANDS[1].length() + 1);

 

Java basically is trying to substring the current String using bigger length than the String's length.

The way it tries to retrieve the id of the selected item afterwards it's ancient so instead you can use

StringTokenizer.

 

The way to use it is the following: 

 




final StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // Unused since it's the admin's command

final int itemId = Integer.parseInt(st.nextToken());

 

Consider the code is written by hand. I just want to give you the idea.

 

I managed to fix the error but i cant make the [X] to appear so that i can execute the command and delete the selected item.

Edited by Drazeal
  • 0
Posted
On 2/21/2021 at 5:59 PM, Drazeal said:

I managed to fix the error but i cant make the [X] to appear so that i can execute the command and delete the selected item.

 

I can't see the html problem. Maybe replace the:

 

sbItems.append("<td><button action=\"bypass -h admin_delete_item " + String.valueOf(item.getObjectId()) + "\" width=16 height=16 back=\"L2UI_ct1.Button_DF_Delete\" fore=\"L2UI_ct1.Button_DF_Delete\">" + "</td></tr>");

 

with:

 

sbItems.append("<td><button value=\"\" action=\"bypass -h admin_delete_item " + String.valueOf(item.getObjectId()) + "\" width=16 height=16 back=\"L2UI_ct1.Button_DF_Delete\" fore=\"L2UI_ct1.Button_DF_Delete\"></td></tr>");

 

Just give it a try nothing to lose.

Guest
This topic is now closed to further replies.


  • Posts

    • Inventory restock: Premium business accounts are now available.   ✔ Wallester Business EU 🇪🇺|💳 Unlimited virtual cards, physical cards, 🏦 multi-currency IBAN, ₿ crypto & stablecoin deposits. ✔ Stripe Business UK 🇬🇧|💳 Instant virtual cards (Visa/Mastercard), high-conversion checkout, multi-currency payouts, ₿ crypto payments, no-code payment links. ✔ Mercury Business US 🇺🇸|🏦 US checking & savings, 💳 unlimited virtual cards, domestic & International wires, native stablecoin settlement. ✔ Payset Business EU 🇪🇺|🏦 Multiple IBANs, UK sort code, SEPA Instant, 💳 unlimited virtual cards, multi-currency accounts. ✔ Novo Business US 🇺🇸|🏦 Business checking account, ACH payments & invoicing, 💳 virtual & physical cards, novo boost.
    • Let me see if I understand correctly, older gentlemen, when a newcomer shows up to create modern things with the help of AI, doing what you charge them to do, you point the finger and laugh. I believe that's why everything is stagnant. The product isn't for programming experts, it's for newcomers. Don't buy from you if they can do it themselves using this base. You're going to deliver a similar product, maybe even worse than this one, so why are you complaining? PowerShell, as you well know, started with it, then came new platforms and new apps, new creation models, all with different languages; I chose the simplest one for my taste. This is about being organized and knowing how to choose the right words for each situation. It's not 100%, but it already gives a good impression. Nothing is 100%, so a topic written by AI, and all the code that you charge an absurd amount for to prohibit and sell hacks, could be open source so that everyone can create new practices, new models, new information for passing packets, prohibiting the use of cheats that cause server owners to break so much. Let's remember that the Admin doesn't always shut down the server; it's the players who find problems and take advantage by buying and reselling items, and they say that the GM shuts down the server every week, but that's a lie. What they do is duplicate items with packages and sell them, but perhaps this could give some future developers a starting point to create their own protection following the model in the initial documentation. Because none of you answer a question from a newbie, you think you're superior because you have knowledge, but with AI, people like that can have the same knowledge as you, but with less practice. And if they practice a lot, 10,000 hours, they can be as good as all of you older developers in the L2J field.
  • 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..