Looks like the help section doesn't get much attention... Anyways, your curly braces are a little messy, are you using an IDE? You should practice formatting your code or at least let your editor do it for you. VSCode, Atom, IntelliJ, Netbeans, Eclipse all have built-in code formatting. Notepad++ can do it too although you need a plugin.
In my opinion, you should always put your curly braces, even in one-line statements. When you're confident you'll never run into this problem again is when you can omit the curly brace.
I believe you need an extra curly brace after line 92, then you have 3 extra curly braces at the end of your code that you can delete. You also need to
parseInt your
fee variable since it's a String and what you need is a number.
You should also stay consistent with your chain of
if-else statements. In status 2 you do an
if-else but it should be an
if-else if.
Code:
} else if (status == 2) {
if (selection == 1) {
//...
} else {
if (selection == 2) {
} else if (selection == 20) {
} //...
}
} else if (status == 3) {
There's no reason to break the chain then continue it in the else block unless you have extra processing or variables to make. Instead, keep everything aligned to keep your flow of code and maintain readability.
Code:
} else if (status == 2) {
if (selection == 1) {
//...
} else if (selection == 2) {
} else if (selection == 20) {
} //...
} else if (status == 3) {
As for making your script more efficient, it really depends on the purpose of your Npc. What I like to do is make my scripts automatically expandable by using arrays (a little bit advanced depending on the size and variety of features in your Npc).
If you make an AIO shop with 62 different shops are you going to manually code each shop in a chain of 62
if-else if statements? No, you shouldn't. Use a loop to print each section then use the selection variable to index the array.