Question: "How can I add items/catogories to this script?"
Short answer: Look at the comments in the script itself, or try things out for a change, worst thing that can happen is you break it, in which case you can retry.
Long answer: I designed this script so that it could be easily edited without touching the main code, but if you are unfamilliar with multidimensional arrays this might be a little confusing, especially when you dont know arrays at all. First lets try to add a new category. this one uses a simple array. To add a new category look at the top of the script, you should see the following:
Code:
var CATEGORY = ["shoes", "hats"];
Now to add a new category, all you have to do is add:
Code:
, "a new category!"
after:
Your new code should look like this:
Code:
var CATEGORY = ["shoes", "hats", "a new category!"];
And ur done! You can do this as many times as you want.
But we aren't done with the categories yet, below the CATEGORY is an array called ITEMS
Code:
var ITEMS = [
[[4000000, 10], [4000017, 20]], // shoes (works like this: [[item id, price], [item id, price]]) you can add more yourself!
[[4000000, 30], [4000017, 40]] // hats
];
Since we added a new category, this itemlist should also be updated!
after each line of this array you can see 2 slashes "//" (this is a comment) with after that shoes and hats, now if you look at CATEGORY you can also see shoes and hats, but since you added another category there is also "a new category!" - under the hats line and above the ]; line, we need to add a new line
Code:
[[4000000, 30], [4000017, 40]] // a new category!
Now it should look like this:
Code:
var ITEMS = [
[[4000000, 10], [4000017, 20]], // shoes (works like this: [[item id, price], [item id, price]]) you can add more yourself!
[[4000000, 30], [4000017, 40]], // hats
[[4000000, 30], [4000017, 40]] // a new category!
];
Now you have succesfully added a category.
Adding items is just as easy!
4000000 and 4000017 are item id's and the number behind it is the price, to add another item simply add
after the existing item, so it should look like this:
Code:
var ITEMS = [
[[4000000, 10], [4000017, 20], [itemid, price], [itemid, price], [itemid, price]], // shoes (works like this: [[item id, price], [item id, price]]) you can add more yourself!
[[4000000, 30], [4000017, 40], [itemid, price]], // hats
[[4000000, 30], [4000017, 40]] // a new category!
];
of course you have to add a real itemid and price!
ok, so far for the item adding.
Question: "I want to have this with votepoints, not eventpoints."
Short answer: edit all getEventPoints and gainEventPoints to > getVotePoints and gainVotePoints.
Long answer: nope, I don't think I can explain that one better...
Question: "I get this error:"
Code:
javax.script.ScriptException: TypeError: Chronos has no such function "getEventPoints" in <eval> at line number 29
at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:586)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:511)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:227)
at scripting.npc.NPCScriptManager.action(NPCScriptManager.java:95)
at net.server.channel.handlers.NPCMoreTalkHandler.handlePacket(NPCMoreTalkHandler.java:71)
at net.MapleServerHandler.messageReceived(MapleServerHandler.java:127)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:690)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:407)
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:236)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)
at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:410)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:710)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:664)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:653)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:67)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1124)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: <eval>:29 TypeError: Chronos has no such function "getEventPoints"
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:58)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:214)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:186)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:173)
at jdk.nashorn.internal.runtime.linker.NashornBottomLinker.linkBean(NashornBottomLinker.java:118)
at jdk.nashorn.internal.runtime.linker.NashornBottomLinker.getGuardedInvocation(NashornBottomLinker.java:73)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:144)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:232)
at jdk.nashorn.internal.scripts.Script$\^eval\_.action(<eval>:29)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:541)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:209)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:185)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:505)
... 25 more
Answer: Look in your source and open client > MapleCharacter.java and look in this file for a method that says something similiar to this:
Code:
public int getEventPoints() {
return eventpoints;
}
except for you, its not called "getEventPoints" - but something else
copy this 'something else' and overrwrite every getEventPoints with your 'something else' in the script, you might have to do the same with gainEventPoints (same procedure with any other kind of point)
Question: "When I click on a category (shoes/hats etc) I dc!"
Answer: Let me guess, you get this error popup:
http://i.imgur.com/gEiPxz5.png
This means you have an invalid item id in your ITEMS array, recheck your items!
Question: "Sometimes (1 outa 6) I see this in the middle of the chat: "Hello, if you see this in game, tell the owner/coder to stop messing with numbers WAAAAY beyond their understanding!" and I have no idea what I did cause I can't admit I touched something"
Answer: Well, I wish you all the luck in the world, altho I doubt there is any hope for you...