Quantcast
Channel: RaGEZONE - MMO Development Forums
Viewing all articles
Browse latest Browse all 35055

Java HELP With Fishing NPC (HeavenMS)

$
0
0
Hello guys, I am in need of a bit of help with this NPC here.
Basically I am not a godly coder so it is the smallest mistakes that screw up my whole code.

This NPC open's and gives a few options...
-Purchase a fishing chair (checks for level 30)
-Warp to various fishing spots
-Trade frog legs for currency (5 legs per currency item)
-Trade fish for mesos (500m ea)
-Trade NX Card for NX Cash

Everything was working fine until i implemented the cm.getText and tried to change the status.
Now my NPC won't open.

Can someone please help me find the issue here, and give me a bit of insight on how to prevent this from happening or maybe even code it more efficiently! THAT WOULD BE GREAT :lol:

Here is my code, I am using HeavenMS Source

Spoiler:
/*
Maple Start Fishing reward NPC
(HeavenMS)

*/

var status = -1;
var item = Array(4001189,5252000); // Item's go here
var fee;

function start() {
action(1, 0, 0);
}

function action(mode, type, selection) {
if (mode != 1) {
cm.dispose();
return;
} else
status++;
if (status == 0) {
cm.sendSimple("You currently have : #r#c4000247##k #v4000247#\r\nYou currently have : #r#c4001189##k #v4001189#\r\nYou currently have : #r#c5252000##k #v5252000#\r\n\r\n#eWelcome!#n I hope you're enjoying Fishing!\r\n#e#bWhat would you like to do?#k#n#n\r\n\r\n#r#L0##eBuy a Fishing Chair#n (Req. Lev. 30)#e\r\n\r\n#L4##n#bWarp to other fishing maps#r\r\n\r\n\r\n#L5#Trade #v4000247# for Cookies\r\n#L6#Sell #v4001189# for Mesos\r\n#L7#Use your #b#t5252000# #v5252000##r to trade for NX Cash.#l");
} else if (status == 1) {
if (selection == 0) {
if (cm.getLevel() <= 30) {
cm.sendOk("Sorry, you must be at least level 30 to buy a Fishing Chair");
cm.dispose();
} else
cm.sendSimple("Are you sure you want to buy\r\n #r1#k #v3011000# for #r1,000,000,000#k mesos?\r\n\r\n#L1##rYes I want to buy it\r\n#L2#No Maybe next time");

} else if (selection == 4) {
cm.sendSimple("Where would you like to go?\r\n\r\n\r\n#L20#On the way to the Harbor\r\n#L21#Pier on the Beach\r\n#L22#The Peaceful Ship\r\n");

} else if (selection == 5) {
cm.sendGetText("Great you want to trade your #v4000247# for some #v4032061#\r\n\r\nHow many did you want to trade?\r\n#r#e5#n legs = 1 Cookie");
} else if (selection == 6) {
cm.sendSimple("You can sell your #v4001189# for 500m each!\r\n\r\n#L30#Sell #r1 #v4001189##k for #r500M#k\r\n#L31#Sell #r2 #v4001189##k for #r1B#k\r\n#L32#Sell #r4 #v4001189##k for #r2B\r\n\r\n#l");
} else if (selection == 7) {
cm.sendSimple("So you want to turn your #v5252000#'s in for some NX Cash??\r\n\r\n#b#L33# Yes.");
cm.dispose();
}
} else if (status == 2) {
if (selection == 1) {
if (cm.getMeso() >= 1000000000) {
cm.gainMeso(-1000000000);
cm.gainItem(3011000, 1);
cm.sendOk("Congrats you've got yourself a Fishing Chair!!\r\n\r\n#r#eHave fun!");
cm.dispose();
} else
cm.sendOk("I'm sorry but it doesn't look like you have enough mesos to purchase this!");
cm.dispose();
} else {
if (selection == 2) {
cm.sendOk("Alright! Next time it is!\r\n\r\nSee ya!");
cm.dispose();

} else if (selection == 20) {
cm.warp(120010000);
cm.dispose();
} else if (selection == 21) {
cm.warp(251000100);
cm.dispose();
} else if (selection == 22) {
cm.warp(541010110);
cm.sendOk("Be careful in the water, you might drown!");
cm.dispose();

} else if (selection == 30) {
if (cm.haveItem(4001189, 1)) {
cm.gainItem(4001189, -1);
cm.gainMeso(500000000);
} else
cm.sendOk("Looks like you don't have enough #v4001189#.\r\nKeep on fishin'");
} else if (selection == 31) {
if (cm.haveItem(4001189, 2)){
cm.gainItem(4001189, -2);
cm.gainMeso(1000000000);
} else
cm.sendOk("Looks like you don't have enough #v4001189#.\r\nKeep on fishin'");
} else if (selection == 32) {
if (cm.haveItem(4001189, 4 && cm.getMeso() <= 145000000)) {
cm.gainItem(4001189, -4);
cm.gainMeso(2000000000);
} else
cm.sendOk("Looks like you don't have enough #v4001189# or you have too many mesos!\r\nPlease try again!");
cm.dispose();
} else if (selection == 33) {
if (!cm.haveItem(5252000 <= 1)) {
cm.sendSimple("Looks like you dont have enough #v5252000#. Plese come back when you have atleast 1.");
} else
cm.sendSimple("test");
}
} else if (status == 3) {
fee = cm.getText();
cm.sendYesNo("Are you sure you want to trade "+ fee +" #v4000247#'s ?");
} else if (status == 4) {
if (!cm.haveItem(4001254, fee)) {
cm.sendOk("#r#eYou don't have that many #v4000247#! You must keep fishing!");
cm.dispose();
} else if (cm.getText() < 5) {
cm.sendOk("#e#r!! You can only trade 5 #v4000247# minimum!");
cm.dispose();
} else if (!cm.haveItem(4001254, fee) + fee * 2 > 1000) {
cm.sendOk("You can only trade 500 #v4000247# at a time!");
cm.dispose();
} else
cm.gainItem(4032061, fee / 5);
cm.gainItem(4001254, -fee);
cm.dispose();
} else
cm.dispose();

}
}
}
}


PS The code is not finished I stopped at the NX option because I was frustrated trying to figure out why it wouldn't open.


ANY HELP IS MUCH APPRECIATED

Viewing all articles
Browse latest Browse all 35055

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>