Whats wrong with this code?
PHP Code:
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
} else {
if (mode == 0 && status == 2) {
cm.sendNext("You need to think about it a little more? Sure, take your time. This is not something you should take lightly. Let me know when you have made your decision.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (cm.getJobId()==0) {
if (status == 0) {
cm.sendNext("So, you want to become a Bowman? Well...you need to meet some requirements to do so. You must be at least #bLevel 10#k. Let's see... Hmmm...");
} else if (cm.getPlayer().getLevel() >= 10) {
cm.changeJobById(300);
cm.sendOk("You now are a sharp-shooting archer! Use your powers wisly!");
cm.dispose();
} else if (cm.getPlayer().getLevel() < 10) {
cm.sendOk("You are not strong enough! GO TRAIN!");
cm.dispose();
}
} else if (cm.getJobId()==300) {
if (cm.getPlayer().getLevel() >= 30) {
if (status == 0)
cm.sendNext("So... your strong enough to take the next step... very well!!.");
else if (status == 1)
cm.sendSimple("Alright, choose your path \r\n#L0#Hunter#l \r\n\#L1#Crowsbow Man#l");
else if (status == 2) {
if (selection == 0) {
cm.sendNext("You have became Hunter!");
cm.changeJobById(310);
cm.dispose();
}else if (selection == 1){
cm.sendNext("You have became Crossbow Man!");
cm.changeJobById(320);
cm.dispose();
} else {
cm.sendOk("You need to train more! Go away and stop wasting my time!");
cm.dispose();
}
}
}
}
}
Any idea whats wrong? Because it don't work...
Re: Whats wrong with this code?
What do you mean it doesn't work. And you spelled awesome incorrectly in your 'Pro' signature.
Also, why is that even a class? That looks extremely stupid. A class with a single, private, void, will never, EVER, print out 'You're awsome!'
Re: Whats wrong with this code?
It doesnt , like it dont do anything when u click on it. And im pretty sure it does do something, oh i dont know maybe prints the stuff that is typed in?
Sent from my HTC Desire HD A9191 using Tapatalk 2
Re: Whats wrong with this code?
sometimes we forget the } at the end...
Normal.
EDIT: Sorry, its not add the } at the end. I seen that you forgot to close the else if at line 48
Code:
}else if (selection == 1){
cm.sendNext("You have became Crossbow Man!");
cm.changeJobById(320);
cm.dispose();
}//Added
Re: Whats wrong with this code?
1 Attachment(s)
Re: Whats wrong with this code?
TO help you, use the notepad++ to see where you are opening and closing a "{ }"
Attachment 138948
When you forget something at your code, the NPC will not open. And you can see a log in your "log" folder. (I see it with MoopleDEV)
Re: Whats wrong with this code?
Okay I get it now, but when ever i select Crossbow man, it dont do anything again?
never mind i got it now. thanks
Re: Whats wrong with this code?
Quote:
Originally Posted by
XemiCal
It doesnt , like it dont do anything when u click on it. And im pretty sure it does do something, oh i dont know maybe prints the stuff that is typed in?
Sent from my HTC Desire HD A9191 using Tapatalk 2
You are an idiot! You can not use Pro.main since it is private. You can only use it inside the 'Pro' class, which ends right after that incorrect print.
Also what's with the variable? So the usage...
Pro.main("My dick is big"); still prints out "You're awsome!" and nothing else.
Code:
class Pro {
public static void main(String args[], int selection) { //lol array?
System.out.println(args[selection]);
}
}
Re: Whats wrong with this code?
Syre, if you want to critizcize his signature don't do it in this post.
as much as I understood, the bug was fixed ?
Re: Whats wrong with this code?
Quote:
Originally Posted by
Syre
Code:
public static void main(String args[], int selection) { //lol array?
lol'd
Re: Whats wrong with this code?
Untested.
PHP Code:
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function jobAdvance() {
var level;
if (cm.getJobId()==311 || cm.getJobId()==321) {
level = 70;
}
if (cm.getJobId()==321 || cm.getJobId()==322) {
level = 120;
}
if (cm.getLevel() >= level) {
cm.sendNext("Congratulations on your job advancement!");
cm.changeJobById(cm.getJobId()+1);
} else {
cm.sendOk("You are not strong enough. GO TRAIN until you are level "+level+"!");
}
cm.dispose();
}
function action(mode, type, selection) {
if (mode == -1 || mode == 0) {
cm.sendNext("You need to think about it a little more? Sure, take your time. This is not something you should take lightly. Let me know when you have made your decision.");
cm.dispose();
return;
} else if (mode == 1) {
status++;
}
if (status == 0) {
switch(cm.getJobId()) {
case 0:
cm.sendNext("So, you want to become a Bowman? Well...you need to meet some requirements to do so. You must be at least #bLevel 10#k. Let's see... Hmmm...");
break;
case 300:
cm.sendSimple("Alright, choose your path \r\n#L0#Hunter#l \r\n\#L1#Crowsbow Man#l");
break;
case 310:
case 320:
case 311:
case 321:
jobAdvance();
break;
}
} else if (status == 1) {
switch(cm.getJobId()) {
case 0:
if (cm.getPlayer().getLevel() >= 10) {
cm.changeJobById(300);
cm.sendOk("You now are a sharp-shooting archer! Use your powers wisely!");
cm.dispose();
return true;
}
break;
case 300:
if (cm.getLevel()>=30) {
cm.sendOk("You have job advanced!");
cm.changeJobById(300 + ((selection + 1) * 10));
cm.dispose();
return true;
}
break;
cm.sendOk("You are not strong enough. GO TRAIN!");
cm.dispose();
}
}
}
1 Attachment(s)
Re: Whats wrong with this code?
It's simply the missing call of function start();
The function is declared but never used in that code.
Use this:
Attachment 138974
// I can't handle with this php tag.. its argueing me with the line breaks
Re: Whats wrong with this code?
Quote:
Originally Posted by
magicsux
It's simply the missing call of function start();
The function is declared but never used in that code.
Use this:
Attachment 138974
// I can't handle with this php tag.. its argueing me with the line breaks
No... in his start function he executes the action method ... that's not the issue.
Re: Whats wrong with this code?
Worst NPC i've seen in a while lololololol even worse than OP's. Good try though! This NPC can be shortened to about 10-15 lines and look super pro :D
Quote:
Originally Posted by
Thane Krios
Untested.
PHP Code:
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function jobAdvance() {
var level;
if (cm.getJobId()==311 || cm.getJobId()==321) {
level = 70;
}
if (cm.getJobId()==321 || cm.getJobId()==322) {
level = 120;
}
if (cm.getLevel() >= level) {
cm.sendNext("Congratulations on your job advancement!");
cm.changeJobById(cm.getJobId()+1);
} else {
cm.sendOk("You are not strong enough. GO TRAIN until you are level "+level+"!");
}
cm.dispose();
}
function action(mode, type, selection) {
if (mode == -1 || mode == 0) {
cm.sendNext("You need to think about it a little more? Sure, take your time. This is not something you should take lightly. Let me know when you have made your decision.");
cm.dispose();
return;
} else if (mode == 1) {
status++;
}
if (status == 0) {
switch(cm.getJobId()) {
case 0:
cm.sendNext("So, you want to become a Bowman? Well...you need to meet some requirements to do so. You must be at least #bLevel 10#k. Let's see... Hmmm...");
break;
case 300:
cm.sendSimple("Alright, choose your path \r\n#L0#Hunter#l \r\n\#L1#Crowsbow Man#l");
break;
case 310:
case 320:
case 311:
case 321:
jobAdvance();
break;
}
} else if (status == 1) {
switch(cm.getJobId()) {
case 0:
if (cm.getPlayer().getLevel() >= 10) {
cm.changeJobById(300);
cm.sendOk("You now are a sharp-shooting archer! Use your powers wisely!");
cm.dispose();
return true;
}
break;
case 300:
if (cm.getLevel()>=30) {
cm.sendOk("You have job advanced!");
cm.changeJobById(300 + ((selection + 1) * 10));
cm.dispose();
return true;
}
break;
cm.sendOk("You are not strong enough. GO TRAIN!");
cm.dispose();
}
}
}
Re: Whats wrong with this code?
Quote:
Originally Posted by
StripedCow
Worst NPC i've seen in a while lololololol even worse than OP's. Good try though! This NPC can be shortened to about 10-15 lines and look super pro :D
I dont know anything about the things you use, just tried to understand what his code was doing and replace if-else-constructs with switches.. Of course it can be done easier if you know how this cm-thing is working.
Gesendet von meinem Nexus 4 mit Tapatalk