Reformat and clean up npc scripts

This commit is contained in:
P0nk
2021-09-09 23:35:02 +02:00
parent 0c1545f81d
commit d893309b4f
665 changed files with 19932 additions and 19046 deletions

View File

@@ -19,6 +19,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Changes the players name.
Can only be accessed with the item 2430026.
*/
@@ -29,36 +30,37 @@ function start() {
}
function action(mode, type, selection) {
if (mode < 0)
if (mode < 0) {
cm.dispose();
else {
if (mode == 1)
} else {
if (mode == 1) {
status++;
else
} else {
status--;
}
if (status == 0 && mode == 1) {
if(cm.haveItem(2430026)) {
cm.sendYesNo("I can change your name for you if you would like?", 1);
} else {
cm.dispose();
}
} else if(status == 1) {
cm.sendGetText("Please input your desired name below.");
} else if(status == 2) {
var text = cm.getText();
if (cm.haveItem(2430026)) {
cm.sendYesNo("I can change your name for you if you would like?", 1);
} else {
cm.dispose();
}
} else if (status == 1) {
cm.sendGetText("Please input your desired name below.");
} else if (status == 2) {
var text = cm.getText();
const Character = Java.type('client.Character');
var canCreate = Character.canCreateChar(text);
if(canCreate) {
cm.getPlayer().setName(text);
cm.sendOk("Your name has been changed to #b" + text + "#k. You will have to login again for this to take effect.", 1);
cm.gainItem(2430026, -1);
} else {
cm.sendNext("I'm afraid you can't use the name #b" + text + "#k or it is already taken.", 1);
}
} else if(status == 3) {
cm.dispose();
cm.getClient().disconnect(false, false);
}
const Character = Java.type('client.Character');
var canCreate = Character.canCreateChar(text);
if (canCreate) {
cm.getPlayer().setName(text);
cm.sendOk("Your name has been changed to #b" + text + "#k. You will have to login again for this to take effect.", 1);
cm.gainItem(2430026, -1);
} else {
cm.sendNext("I'm afraid you can't use the name #b" + text + "#k or it is already taken.", 1);
}
} else if (status == 3) {
cm.dispose();
cm.getClient().disconnect(false, false);
}
}
}