Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Solved] [Lithium] What's wrong with my Donator NPC?

Skilled Illusionist
Joined
Dec 7, 2012
Messages
330
Reaction score
24
Hey everyone, I edited this Vote Point NPC that my buddy badger wrote, and attempted to turn it into a donator NPC. Every time I click on the NPC, I disconnect and get an error that says something has gone wrong with the client. There are no BAT errors.

I'm thinking I may need to add something to MapleCharacter.java - Or possibly change what I did in the NPCConversationManager.java

Can anyone offer me some insight / help?

My script:
Code:
/*
Written by: potimus 
*/

var status;
var sCube = 5062002;
var hunters = 2450000;
var potscroll = 2049406;
var panda = 3010131;
var maplechair = 3010145;
var badge = 1182006;
var ttmedal = 1142247;
var specs = 1022082;
var branch = 1012107;
var wabr = 1112663;
var vest = 1042191;
var bring = 1112665;
var gring = 1112664;
var stirgepants = 1060133;
var stirgeskirt = 1061155;


function start() {
    status = -1;
    action (1, 0, 0); 
}

function action(mode, type, selection) {
    if (mode == 1) {
		status++;
	} else {
		status--;
	}
	
    if (status == 0) {
		cm.sendSimple("You can exchange your Donator Points here for some sweet items!" +
						"\r\nChoose one!" + " You have " + cm.numOfPoints() + " donator points." +
						"\r\n#L0#Trade 5,000 Donator Points for 25 #i5062002#" +
						"\r\n#L1#Trade 10,000 Donator Points for 50 #i5062002#" +
						"\r\n#L2#Trade 20,000 Donator Points for 120 #i5062002#" +
						"\r\n#L3#Trade 250 Donator Points for #i2450000#" +
						"\r\n#L4#Trade 1,000 Donator Points for #i2049406#" +
						"\r\n#L5#Trade 3,000 Donator Points for #i3010131#" +
						"\r\n#L6#Trade 3,000 Donator Points for #i3010145#" +
						"\r\n#L7#Trade 3,500 Donator Points for #i1182006#" +
						"\r\n#L8#Trade 3,500 Donator Points for #i1142247#" +
						"\r\n#L9#Trade 4,000 Donator Points for #i1022082#" +
						"\r\n#L10#Trade 5,000 Donator Points for #i1012107#" +
						"\r\n#L11#Trade 6,000 Donator Points for #i1112663#" +
						"\r\n#L12#Trade 6,000 Donator Points for #i1042191#" +
						"\r\n#L13#Trade 7,000 DOnator Points for #i1112665#" +
						"\r\n#L14#Trade 7,000 Donator Points for #i1112664#" +
						"\r\n#L15#Trade 7,500 Donator Points for #i1060133#" +
						"\r\n#L16#Trade 7,500 Donator Points for #i1061155#");
	} else if (status == 1) {
		if (selection == 0 &&  cm.numOfVP() >= 5000) {
			cm.gainItem(sCube, 25)
			cm.setNumOfPoints(-5000); 
			cm.sendOk("You have traded 5,000 Donator Points for 25 #i5062002#");
			cm.dispose(); 
		} else if (selection == 1 && cm.numOfPoints() >= 10000) {
			cm.gainItem(sCube, 50);
			cm.setNumOfVP(-10000);
			cm.sendOk("You have traded 10,000 Donator Points for 50 #i5062002#");
			cm.dispose();
		} else if (selection == 2 && cm.numOfPoints() >= 25000) {
			cm.gainItem(sCube, 120);
			cm.setNumOfVP(-25000);
			cm.sendOk("You have traded 25,000 Donator Points for 120 #i5062002#");
			cm.dispose();
		} else if (selection == 3 && cm.numOfPoints() >= 250) {
			cm.gainItem(hunters, 1);
			cm.setNumOfVP(-250);
			cm.sendOk("You have traded 250 Donator Points for #i2450000#");
			cm.dispose();
		} else if (selection == 4 && cm.numOfPoints() >= 1000) {
			cm.gainItem(potscroll, 1);
			cm.setNumOfVP(-1000);
			cm.sendOk("You have traded 1000 Donator Points for #i2049406#");
			cm.dispose();
		} else if (selection == 5 && cm.numOfPoints() >= 3000) {
			cm.gainItem(panda, 1);
			cm.setNumOfVP(-3000);
			cm.sendOk("You have traded 3000 Donator Points for #i3010131#");
			cm.dispose();
		} else if (selection == 6 && cm.numOfPoints() >= 3000) {
			cm.gainItem(maplechair, 1);
			cm.setNumOfVP(-3000);
			cm.sendOk("You have traded 3000 Donator Points for #i3010145#");
			cm.dispose();
		} else if (selection == 7 && cm.numOfPoints() >= 3500) {
			cm.gainItem(badge, 1);
			cm.setNumOfVP(-3500);
			cm.sendOk("You have traded 3500 Donator Points for #i1182006#");
			cm.dispose();
		} else if (selection == 8 && cm.numOfPoints() >= 3500) {
			cm.gainItem(ttmedal, 1);
			cm.setNumOfVP(-3500);
			cm.sendOk("You have traded 3500 Donator Points for #i1142247#");
			cm.dispose();
		} else if (selection == 9 && cm.numOfPoints() >= 4000) {
			cm.gainItem(specs, 1);
			cm.setNumOfVP(-4000);
			cm.sendOk("You have traded 4000 Donator Points for #i1022082#");
			cm.dispose();
		} else if (selection == 10 && cm.numOfPoints() >= 5000) {
			cm.gainItem(branch, 1);
			cm.setNumOfVP(-5000);
			cm.sendOk("You have traded 5000 Donator Points for #i1012107#");
			cm.dispose();
		} else if (selection == 11 && cm.numOfPoints() >= 6000) {
			cm.gainItem(wabr, 1);
			cm.setNumOfVP(-6000);
			cm.sendOk("You have traded 6000 Donator Points for #i1112663#");
			cm.dispose();
		} else if (selection == 12 && cm.numOfPoints() >= 6000) {
			cm.gainItem(vest, 1);
			cm.setNumOfVP(-6000);
			cm.sendOk("You have traded 6000 Donator Points for #i1042191#");
			cm.dispose();
		} else if (selection == 13 && cm.numOfPoints() >= 7000) {
			cm.gainItem(bring, 1);
			cm.setNumOfVP(-7000);
			cm.sendOk("You have traded 7000 Donator Points for #i1112665#");
			cm.dispose();
		} else if (selection == 14 && cm.numOfPoints() >= 7000) {
			cm.gainItem(gring, 1);
			cm.setNumOfVP(-7000);
			cm.sendOk("You have traded 7000 Donator Points for #i1112664#");
			cm.dispose();
		} else if (selection == 15 && cm.numOfPoints() >= 7500) {
			cm.gainItem(stirgepants, 1);
			cm.setNumOfVP(-7500);
			cm.sendOk("You have traded 7500 Donator Points for #i1060133#");
			cm.dispose();
		} else if (selection == 16 && cm.numOfPoints() >= 7500) {
			cm.gainItem(stirgeskirt, 1);
			cm.setNumOfVP(-7500);
			cm.sendOk("You have traded 7500 Donator Points for #i1061155#");
			cm.dispose();
		} else {
			cm.dispose();
		}			
	}
}

I added these 2 pieces of code in my NPCConversationManager.java - I simply changed the VPoints one that was already there - The vote point ones will also be included in the code.

Code:
/*Start of Custom Features*/
    public void gainAPS(int gain) {
        getPlayer().gainAPS(gain);
    }
    public int numOfVP() {
        return c.getPlayer().getVPoints();
    }
    public void setNumOfVP(int amount) {
        c.getPlayer().setVPoints(c.getPlayer().getVPoints() + amount);
    }
    public void setCSPoints(int amount) {
        c.getPlayer().modifyCSPoints(amount);
    }
	public int numOfPoints() {                         //these are the codes I added here
        return c.getPlayer().getPoints();
    }
    public void setNumOfPoints(int amount) {
        c.getPlayer().setPoints(c.getPlayer().getPoints() + amount);
    }
    /*End of Custom Features*/
}
 
Last edited:
Skilled Illusionist
Joined
Dec 7, 2012
Messages
330
Reaction score
24
Re: [Lithium] What's wrong with my Donator NPC?

Can anybody help me out with this?

To be more specific, the client gives me a runtime error, and says that it has terminated in an unusual way.
 
Upvote 0
Initiate Mage
Joined
Jan 13, 2013
Messages
15
Reaction score
0
Re: [Lithium] What's wrong with my Donator NPC?

First question is what is up with all the variables in the script? I find them kind of useless pieces of code when you can just use the ID..
 
Upvote 0
Skilled Illusionist
Joined
Dec 7, 2012
Messages
330
Reaction score
24
Re: [Lithium] What's wrong with my Donator NPC?

The original writer had those in there. I believe he was going to use them for something else originally, and just didn't remove them.

So I removed the edits I made in NPCConversationManager.java - The NPC no longer crashes me, but when I click it does nothing... However I do get this bat error. Anyone know how to fix it?

BAT error after clicking the NPC
Code:
Error executing NPC script, NPC ID : 2091010.javax.script.ScriptException: sun.o
rg.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function numOfP
oints in object scripting.NPCConversationManager@61aa2f. (<Unknown source>#36) i
n <Unknown source> at line number 36
 
Upvote 0
至死不渝
Joined
Dec 31, 2008
Messages
454
Reaction score
33
Re: [Lithium] What's wrong with my Donator NPC?

function numOfPoints is missing, define it in NPCConvo LOL. But then seeing that error, you can pretty much narrow the crash problem down to something that is coded wrongly in your numofpoints function.

Edit: Wait actually you just add the functions you deleted back one by one and when the game starts crashing, you would know that the last function you added is causing it.
 
Upvote 0
Skilled Illusionist
Joined
Dec 7, 2012
Messages
330
Reaction score
24
Re: [Lithium] What's wrong with my Donator NPC?

This is the function crashing me
Code:
public int numOfPoints() {                         
        return c.getPlayer().getPoints();
    }

But when I use just the other function, I get this bat error
Code:
Error executing NPC script, NPC ID : 2091010.javax.script.ScriptException: sun.o
rg.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function numOfP
oints in object scripting.NPCConversationManager@61aa2f. (<Unknown source>#36) i
n <Unknown source> at line number 36

The BAT error is referring to line 36, I think that may refer to line 36 of the NPCConversationManager, which is this
Code:
import client.MapleCharacter;

Am I maybe missing something in my MapleCharacter.java?
 
Upvote 0
至死不渝
Joined
Dec 31, 2008
Messages
454
Reaction score
33
Re: [Lithium] What's wrong with my Donator NPC?

This is the function crashing me
Code:
public int numOfPoints() {                         
        return c.getPlayer().getPoints();
    }

But when I use just the other function, I get this bat error
Code:
Error executing NPC script, NPC ID : 2091010.javax.script.ScriptException: sun.o
rg.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function numOfP
oints in object scripting.NPCConversationManager@61aa2f. (<Unknown source>#36) i
n <Unknown source> at line number 36

The BAT error is referring to line 36, I think that may refer to line 36 of the NPCConversationManager, which is this
Code:
import client.MapleCharacter;

Am I maybe missing something in my MapleCharacter.java?

No. It is telling you that in the NPC on line 36, you are using the function "numOfPoints" which isn't existent anywhere in your NPCConversationManager.
 
Upvote 0
butt > Tits
Member
Joined
Feb 16, 2009
Messages
658
Reaction score
96
Re: [Lithium] What's wrong with my Donator NPC?

Thank and rep me.

PHP:
/*
Written by: potimus 
*/

var status;

var gainItem = [5062002, 5062002, 5062002, 2450000, 2049406, 3010131, 3010145, 1182006, 1142247, 1022082, 1012107, 1112663, 1042191, 1112665, 1112664, 1060133, 1061155];
var amountItem = [25, 50, 120, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
var amountVotePoints = [5000, 10000, 20000, 250, 1000, 3000, 3000, 3500, 3500, 4000, 5000, 6000, 6000, 7000, 7000, 7500, 7500];


function start() {
    status = -1;
    action (1, 0, 0); 
}

function action(mode, type, selection) {
	status++;
    if (mode != 1) {
		cm.dispose();
		return;
	}
    if (status == 0) {
		var text = "You can exchange your Donator Points here for some sweet items! \r\nChoose one!" + " You have " + cm.numOfPoints() + " donator points.\r\n";
		for (var i = 0; i < gainItem.Length; i++)
		{
			text += "\r\n#L" + i + "#Trade " + amountVotePoints[i] + " Donator Points for " + amountItem[i] + " #i" + gainItem[i] + "#";
		}
		cm.sendSimple("You can exchange your Donator Points here for some sweet items!" +
			"\r\nChoose one!" + " You have " + cm.numOfPoints() + " donator points." +
			"\r\n#L0#Trade 5,000 Donator Points for 25 #i5062002#" +
			"\r\n#L1#Trade 10,000 Donator Points for 50 #i5062002#" +
			"\r\n#L2#Trade 20,000 Donator Points for 120 #i5062002#" +
			"\r\n#L3#Trade 250 Donator Points for #i2450000#" +
			"\r\n#L4#Trade 1,000 Donator Points for #i2049406#" +
			"\r\n#L5#Trade 3,000 Donator Points for #i3010131#" +
			"\r\n#L6#Trade 3,000 Donator Points for #i3010145#" +
			"\r\n#L7#Trade 3,500 Donator Points for #i1182006#" +
			"\r\n#L8#Trade 3,500 Donator Points for #i1142247#" +
			"\r\n#L9#Trade 4,000 Donator Points for #i1022082#" +
			"\r\n#L10#Trade 5,000 Donator Points for #i1012107#" +
			"\r\n#L11#Trade 6,000 Donator Points for #i1112663#" +
			"\r\n#L12#Trade 6,000 Donator Points for #i1042191#" +
			"\r\n#L13#Trade 7,000 DOnator Points for #i1112665#" +
			"\r\n#L14#Trade 7,000 Donator Points for #i1112664#" +
			"\r\n#L15#Trade 7,500 Donator Points for #i1060133#" +
			"\r\n#L16#Trade 7,500 Donator Points for #i1061155#");
	} else if (status == 1) {
		if (cm.numOfPoints() >= amountVotePoints[selection])
		{
			cm.gainItem(gainItem[selection], amountItem[selection]);
			cm.gainNumOfPoints(-amountVotePoints[selection]);
			cm.sendOk("You have traded " + amountVotePoints[selection] + " Donator Points for " + amountItem[selection] + " #i" + gainItem[selection] + "#.");
		}
		cm.dispose();
	}			
}
 
Upvote 0
Skilled Illusionist
Joined
Dec 7, 2012
Messages
330
Reaction score
24
Re: [Lithium] What's wrong with my Donator NPC?

Thanks for the help ^

Turns out the main issue was one of the items codes was corrupt, that's why I was crashing...
 
Upvote 0
Back
Top