Re: [Tut] Learning NPC scripts (beginner's guide)
Hey can u tell me whats wrong with this i just cant get it to work it would b a big help.
Sorry messed this 1 up so i reposted under it
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}
else {
if (status >= 2 && mode == 0) {
cm.sendOk("Goodbye");
cm.dispose();
return;
}
if (mode == 1) {
status++;
}
else {
status--;
}
if (status == 0) {
cm.sendNext("hello, how are you?");
}
else if (status == 1) {
cm.sendSimple("Have you come to trade #b#v4000313##k\r\n#Lo#Yes, lets trade.#l\r\n#L1#Sorry, I did'nt mean to bother you.#l");
}
else if (status == 2) {
if (selection == 0) {
cm.sendSimple("Okay what will it be?\r\n#L0#3 #b#v4000313##k = #b#v1902002##k#l\r\n#L1#1 #b#v4000313##k = #b#v2040807##k#l");
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
else if (status == 3) {
if (selection == 0) {
if(cm.haveItem(4000313, 3)) {
cm.gainItem(1902002, 1);
cm.gainItem(4000313, -3);
cm.dispose();
}
else if (selection == 1) {
if(cm.haveitem(4000313, 1)) {
cm.gainItem(2040807, 1);
cm.gainItem(4000313, -1);
cm.dispose();
}
}
}
}
Hey can u tell me whats wrong with this i just cant get it to work it would b a big help.
Sorry messed this 1 up so i reposted under it
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}
else {
if (status >= 2 && mode == 0) {
cm.sendOk("Goodbye");
cm.dispose();
return;
}
if (mode == 1) {
status++;
}
else {
status--;
}
if (status == 0) {
cm.sendNext("hello, how are you?");
}
else if (status == 1) {
cm.sendSimple("Have you come to trade #b#v4000313##k\r\n#Lo#Yes, lets trade.#l\r\n#L1#Sorry, I did'nt mean to bother you.#l");
}
else if (status == 2) {
if (selection == 0) {
cm.sendSimple("Okay what will it be?\r\n#L0#3 #b#v4000313##k = #b#v1902002##k#l\r\n#L1#1 #b#v4000313##k = #b#v2040807##k#l");
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
else if (status == 3) {
if (selection == 0) {
if(cm.haveItem(4000313, 3)) {
cm.gainItem(1902002, 1);
cm.gainItem(4000313, -3);
cm.dispose();
}
else if (selection == 1) {
if(cm.haveitem(4000313, 1)) {
cm.gainItem(2040807, 1);
cm.gainItem(4000313, -1);
cm.dispose();
}
}
}
}