My first code more complex code
Hey guys I made a my first code (other than simple warps and whatnot). Well obviously, its not working as I'm a total noob. Also, I used this layout to help me:
PHP Code:
var status;
function start() { // starts the NPC
status = -1; // sets the status of the NPC to -1
action(1, 0, 0); // sets the mode to 1, type to 0, and selection to 0 for the NPC
} // closes off the start function
function action(mode, type, selection) { // calls what you set above in function start, almost all actions are done here
if (mode == 1) { // the mode is set to 1 because of the function start, as shown above
status++; // advances the NPC to the next status, in this case, status 0
}else{ // if mode does not equal 1
status--; // does not advance the NPC to the next status.
}
if (status == 0) { // if mode was 1, status would move from -1 to 0. If status is 0, these actions will happen
cm.sendSimple("Hello. I am going to show you how to use #belse#k and #bif#k. Are you ready? \r\n #L0# Yes, I am. #l \r\n #L1# No, I'm not. #l"); // Opens a window with 2 choices (selections)
} else if (status == 1) { // NPC advances to next status if a selection is chosen.
if (selection == 0) { // selection 0 is #L0#, "Yes, I am."
if (cm.haveItem(4001129, 10)) { // checks for an item
cm.sendOk("IF you chose selection 0, or in easier terms, the first choice, I will say this."); // IF you have the item, this will show
cm.dispose();
}else{
cm.sendOk("I'm sorry, you don't have the item."); // ELSE, you don't have the item.
cm.dispose();
}
} else if (selection == 1) { // "No, I'm not."
cm.sendOk("ELSE IF you chose selection 1, I will say this.");
cm.dispose();
}
}
}
Heres my code:
PHP Code:
//My First code - lordpeter
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) {
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
} else if (status == 1) {
if (selection == 0) {
if (cm.getLevel(10);) {
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.changeJob(1100);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
cm.getLevel(10);
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.changeJob(1200);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
} else if (selection == 2) {
cm.getLevel(10);
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.changeJob(1500);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
cm.dispose();
} else if (selection == 3) {
cm.getLevel(10);
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.changeJob(1400);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
} else if (selection == 4) {
cm.getLevel(10);
cm.sendOk("Congrats, you are now a WindArcher!");
cm.changeJob(1300);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
Re: My first code more complex code
This should work
PHP Code:
//My First code - lordpeter
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
} // closes off the start function
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) { // if mode was 1, status would move from -1 to 0. If status is 0, these actions will happen
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.changeJobById(1100);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.changeJobById(1200);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.changeJobById(1500);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.changeJobById(1400);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a WindArcher!");
cm.changeJobById(1300);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
This should work
PHP Code:
//My First code - lordpeter
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
} // closes off the start function
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) { // if mode was 1, status would move from -1 to 0. If status is 0, these actions will happen
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.changeJobById(1100);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.changeJobById(1200);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.changeJobById(1500);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.changeJobById(1400);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.sendOk("Congrats, you are now a WindArcher!");
cm.changeJobById(1300);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
many thanks to you once again. But can you please tell me what I did wrong? I wanna learn to code!
EDIT: i get dc'd
Re: My first code more complex code
Sorry about that. This should work
PHP Code:
//My First code - lordpeter
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
} // closes off the start function
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) { // if mode was 1, status would move from -1 to 0. If status is 0, these actions will happen
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.changeJobById(1100);
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.changeJobById(1200);
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.changeJobById(1500);
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.changeJobById(1400);
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.changeJobById(1300);
cm.sendOk("Congrats, you are now a WindArcher!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
Sorry about that. This should work
PHP Code:
//My First code - lordpeter
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
} // closes off the start function
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) { // if mode was 1, status would move from -1 to 0. If status is 0, these actions will happen
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.changeJobById(1100);
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.changeJobById(1200);
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.changeJobById(1500);
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.changeJobById(1400);
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.changeJobById(1300);
cm.sendOk("Congrats, you are now a WindArcher!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
Still doesn't work..:O
Re: My first code more complex code
What do you mean by doesn't work?
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
What do you mean by doesn't work?
Well it Disconnects me from the game.
Re: My first code more complex code
When do you disconnect from game?
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
When do you disconnect from game?
As soon as I click on the NPC
and I tried 4 different NPC's
batch file gives me this error:
http://i42.tinypic.com/2yxkg75.png
Re: My first code more complex code
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}else if (mode == 0){
cm.dispose();
return;
} else {
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.changeJobById(1100);
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.changeJobById(1200);
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.changeJobById(1500);
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.changeJobById(1400);
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.changeJobById(1300);
cm.sendOk("Congrats, you are now a WindArcher!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
}
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}else if (mode == 0){
cm.dispose();
return;
} else {
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
if (selection == 0) {
if (cm.getLevel() > 9) {
cm.changeJobById(1100);
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
if (cm.getLevel() > 9) {
cm.changeJobById(1200);
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.getLevel() > 9) {
cm.changeJobById(1500);
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 3) {
if (cm.getLevel() > 9) {
cm.changeJobById(1400);
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 4) {
if (cm.getLevel() > 9) {
cm.changeJobById(1300);
cm.sendOk("Congrats, you are now a WindArcher!");
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
}
}
It gives me what the guy is supposed to say :O
Re: My first code more complex code
Soo what's the issue now?
Posted via Mobile Device
Re: My first code more complex code
PHP Code:
function start() { // opening dialog.
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l\r\n#L1#BlazeWizard#l\r\n#L2#WindArcher#l\r\n#L3#NightWalker#l\r\n#L4#ThunderBreaker#l");
}
function action(m,t,s) {
if (m < 1 || cm.getLevel < 10) { // level check / end chat
cm.dispose();
return;
}
cm.changeJobById(1100 + 100*s); // job change
cm.sendOk("You are now a " + cm.getJobName() + ". Congratulations."); // dialog
cm.dispose(); // dispose
}
Here you go.
Be sure to use a scriptable NPC.
Re: My first code more complex code
Quote:
Originally Posted by
TiredGuy
Soo what's the issue now?
Posted via Mobile Device
Nothing happens when I click on the NPC. What NPC ID do you advise me to use?
Okay okay, its werid. I click on the NPC, i hear that job advance thing but also i get dissconnected with it saying "invalid pointer -2something"
http://i42.tinypic.com/2yxkg75.png
this is in the batch
Quote:
Originally Posted by
Standardize
PHP Code:
function start() { // opening dialog.
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l\r\n#L1#BlazeWizard#l\r\n#L2#WindArcher#l\r\n#L3#NightWalker#l\r\n#L4#ThunderBreaker#l");
}
function action(m,t,s) {
if (m < 1 || cm.getLevel < 10) { // level check / end chat
cm.dispose();
return;
}
cm.changeJobById(1100 + 100*s); // job change
cm.sendOk("You are now a " + cm.getJobName() + ". Congratulations."); // dialog
cm.dispose(); // dispose
}
Here you go.
Be sure to use a scriptable NPC.
woah thanks but umm can you please say whats wrong with mine? I wanna learn to code :O
Re: My first code more complex code
PHP Code:
var status;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1) {
status++;
}else{
status--;
}
if (status == 0) {
cm.sendSimple("Hello. Would you like to become a cygnus knight? Choose which job: \r\n #L0#DawnWarrior#l \r\n #L1#BlazeWizard #l \r\n #L2#ThunderBreaker #l \r\n #L3#NightWalker #l \r\n #L4#WindArcher #l");
} else if (status == 1) {
if (selection == 0) {
---if (cm.getLevel(10);) { ---
cm.sendOk("Congrats, you are now a DawnWarrior!");
cm.changeJob(1100);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
} else if (selection == 1) {
---cm.getLevel(10);---
cm.sendOk("Congrats, you are now a BlazeWizard!");
cm.changeJob(1200);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
} else if (selection == 2) {
---cm.getLevel(10);---
cm.sendOk("Congrats, you are now a ThunderBreaker!");
cm.changeJob(1500);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
cm.dispose();
} else if (selection == 3) {
--- cm.getLevel(10);---
cm.sendOk("Congrats, you are now a Nightwalker!");
cm.changeJob(1400);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
} else if (selection == 4) {
---cm.getLevel(10);---
cm.sendOk("Congrats, you are now a WindArcher!");
cm.changeJob(1300);
cm.dispose();
}else{
cm.sendOk("I'm sorry, you need to train more.");
cm.dispose();
}
}
}
The lines with --- <code> --- are the parts where there are errors.
You're also missing a dispose block.