Skip to content

Admin command problem

Featured Replies

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

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.

 

  • Author
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

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.

  • Author

tried it. still no [X]... 

tried everything i can think of...

  • Vision locked this topic
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.