[Release]Custom NX selling NPC![OdinMS]
Hey, I just made this custom NPC which sells NX cash for mesos. Yes I have tested this, and it works great and whatnot. To use this NPC you are going to need a localhost with cashshop enabled, and then go to your src\net\sf\odinms\scripting\npc and right click on npcconversationmanager.java and hit edit. [Note: If you already have the cm.modifyNX(), then skip this step.]
Code:
public void gainFame(int fame) {
getPlayer().gainFame(fame);
getPlayer().updateSingleStat(MapleStat.FAME, Integer.valueOf(getPlayer().getFame()));
getPlayer().getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You have gained (+" + fame +") fame."));
}
Or just look for the last one of those public voids. and after it place this:
Code:
public void modifyNX(int amount, int type) {
getPlayer().modifyCSPoints(type, amount);
if (amount > 0) {
getClient().getSession().write(MaplePacketCreator.serverNotice(5, "You have gained NX Cash (+" + amount +")."));
} else {
getClient().getSession().write(MaplePacketCreator.serverNotice(5, "You have lost NX Cash (" + (amount) +")."));
}
}
Note: Some repacks already have this code in them. To find out if you already have it, just do a ctrl + F and search for modifyNX.
Now that that is taken care of, either download my NPC from here.
Or, just copy and paste this code into the NPC of your choosing:
Code:
var status = 0;
var selected;
var fee;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0) {
cm.sendOk("Later.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hello #h #, I am the NX seller of MaplePenguin.");
} else if (status == 1) {
cm.sendGetText("How much NX do you wish to purchase?\r\nRemember, NX costs 1million mesos per 1k NX.");
} else if (status == 2) {
selected = cm.getText();
fee = cm.getText() * 1000;
cm.sendYesNo("Are you sure you want to buy " + selected + " NX for " + fee + " mesos?, #h #?");
} else if (status == 3) {
if (cm.getMeso() < fee) {
cm.sendOk("You dont have enough money. Go get a job you bum!");
cm.dispose();
} else {
cm.modifyNX(selected, 0);
cm.gainMeso(selected * -1000);
cm.sendNext("Done! You have now received " + selected + " NX and " + fee + " mesos have been deducted from your account.");
}
} else if (status == 4) {
cm.sendOk("Have fun.\r\n\r\n\r\nThis NPC was made by Sleepwlker!")
cm.dispose();
}
}
}
The default NPC that I used was Mr. Thunder in Perion, or NPC #1022003.
The NPC brings up a window, allowing you to buy NX for 1k NX per 1million mesos, and then brings up a textbox allowing you to type in exactly how much NX you want.
Credits: Me for creating it.
iGoofy for the cm.modifyNx()
Edit1: Also, if you edit NPCConversationManager,java, you WILL have to compile afterwards. If you don't know how to compile, I suggest using Innovative's guide to compiling with netbeans..
Oh, and off-topic, I am looking for a GM+dev spot if anyone needs a GM+Dev. D: Just leave a comment with your server info and stuff and I'll get back to you eventually.
(Why does nobody comment?)
Thanks for all the comments!
Oh, and thank for the dev/gm offers too, but I'm going to have to decline those because of my new pserver.
I decided to bring back DorkMS as CipherMS.
Edit2: I don't think I'll ever try to host my own server again, so I am looking for a GM/dev spot on a server if anyone reads this post ever.
Re: [Release]Custom NX selling NPC![OdinMS]
Re: [Release]Custom NX selling NPC![OdinMS]
Wow. Nice o-o; I might use this...
Re: [Release]Custom NX selling NPC![OdinMS]
Quote:
Originally Posted by
itadakimasu
Wow. Nice o-o; I might use this...
Thanks, it's the first NPC I've coded from scratch.
(I know no java.)
Off-topic: Anyone got any GM/Dev spots open in their servers?
Re: [Release]Custom NX selling NPC![OdinMS]
This is cool :P
I see my gainfame function :P
Using this :)
Re: [Release]Custom NX selling NPC![OdinMS]
Quote:
Originally Posted by
megoesrawr
This is cool :P
I see my gainfame function :P
Using this :)
Ah, so you made the gainFame function?
I just started sorta learning Java. I don't know much, but I'm getting pretty good at NPCs and commands.
Re: [Release]Custom NX selling NPC![OdinMS]
Oh btw... You can type in - lol
I'll fix the script for you
Re: [Release]Custom NX selling NPC![OdinMS]
Re: [Release]Custom NX selling NPC![OdinMS]
Sorry took a nap... Anyways try this code... Didn't test yet
Code:
var status = 0;
var selected;
var fee;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0) {
cm.sendOk("Later.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hello #h #, I am the NX seller of SpinMs");
} else if (status == 1) {
cm.sendGetText("How much NX do you wish to purchase?\r\nThe #rrate#k for now is #b10k = 1 billion mesos#k");
} else if (status == 2) {
selected = cm.getText();
fee = cm.getText() * 100000;
cm.sendYesNo("Are you sure you want to buy " + selected + " NX for " + fee + " mesos?, #h #?");
} else if (status == 3) {
if (cm.getMeso() < fee || cm.getText() < 0) {
cm.sendOk("#rgtfo#k you #ghobo#k!");
cm.dispose();
} else {
cm.modifyNX(selected, 0);
cm.gainMeso(selected * -100000);
cm.sendNext("Done! You have now received " + selected + " NX and " + fee + " mesos have been deducted from your account.");
}
} else if (status == 4) {
cm.sendOk("Have fun spending your nx you nx wh0re luls.")
cm.dispose();
}
}
}
Re: [Release]Custom NX selling NPC![OdinMS]
Okay, I just tested it... It works 100% :)
Re: [Release]Custom NX selling NPC![OdinMS]
Quote:
Originally Posted by
megoesrawr
Okay, I just tested it... It works 100% :)
Yeap. I tested it on my server too.
Re: [Release]Custom NX selling NPC![OdinMS]
Re: [Release]Custom NX selling NPC![OdinMS]
Quote:
Originally Posted by
sadekula
Nice
Thanks! :D
Re: [Release]Custom NX selling NPC![OdinMS]
Re: [Release]Custom NX selling NPC![OdinMS]
OMG OMG OMG TY TY TY :D yes i r nib