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.
×
×
  • Create New...