Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Npc help

Experienced Elementalist
Joined
Apr 18, 2009
Messages
211
Reaction score
38
You've got so many errors in there that I don't even wanna bother trying to fix them all, so I just recreated it.

PHP:
var status = -1;
var sel;
var item = [4032522, 4032523, 4032524];
var gain = [100, 500, 1000];

function start() {
	var text = "Insert beginning text here"; // Modify to your liking. This will appear before the selections
	for (var i = 0; i < item.length; i++) {
		text += "#b\r\n#L" + i + "##i" + item[i] + "# #v" + item[i] + "# for " + gain[i] + "#l";
	}
	cm.sendSimple(text);
}

 function action(mode, type, selection) {
	if (mode == 1) {
		status++;
	} else {
		cm.dispose();
		return;
	}
	if (status == 0) {
		sel = selection;
		cm.sendYesNo("Are you sure you'd like to trade #i" + item[selection] + "# #v" + item[selection] + "# for " + gain[selection] + "?");
	} else if (status == 1) {
		if (cm.haveItem(item[sel])) {
			cm.gainItem(item[sel], -1);
			cm.getPlayer().modifyCSPoints(1, gain[sel], false);
			cm.sendOk("Enjoy your reward");
		} else {
			cm.sendOk("Please make sure you have #i" + item[sel] + "# #v" + item[sel] + "#.");
		}
		cm.dispose();
	}
}
 
Upvote 0
Initiate Mage
Joined
Feb 14, 2011
Messages
58
Reaction score
2
You've got so many errors in there that I don't even wanna bother trying to fix them all, so I just recreated it.

PHP:
var status = -1;
var sel;
var item = [4032522, 4032523, 4032524];
var gain = [100, 500, 1000];

function start() {
	var text = "Insert beginning text here"; // Modify to your liking. This will appear before the selections
	for (var i = 0; i < item.length; i++) {
		text += "#b\r\n#L" + i + "##i" + item[i] + "# #v" + item[i] + "# for " + gain[i] + "#l";
	}
	cm.sendSimple(text);
}

 function action(mode, type, selection) {
	if (mode == 1) {
		status++;
	} else {
		cm.dispose();
		return;
	}
	if (status == 0) {
		sel = selection;
		cm.sendYesNo("Are you sure you'd like to trade #i" + item[selection] + "# #v" + item[selection] + "# for " + gain[selection] + "?");
	} else if (status == 1) {
		if (cm.haveItem(item[sel])) {
			cm.gainItem(item[sel], -1);
			cm.getPlayer().modifyCSPoints(1, gain[sel], false);
			cm.sendOk("Enjoy your reward");
		} else {
			cm.sendOk("Please make sure you have #i" + item[sel] + "# #v" + item[sel] + "#.");
		}
		cm.dispose();
	}
}

thanks but how do i insert the quantity? instead of exchanging 1 at a time you can exchange as many you have?
 
Upvote 0
Experienced Elementalist
Joined
Apr 18, 2009
Messages
211
Reaction score
38
Here you are...

PHP:
var status = -1;
var sel;
var multiplier;
var total;
var item = [4032522, 4032523, 4032524];
var gain = [100, 500, 1000];

function start() {
    var text = "Insert beginning text here"; // Modify to your liking. This will appear before the selections
    for (var i = 0; i < item.length; i++) {
        text += "#b\r\n#L" + i + "##i" + item[i] + "# #v" + item[i] + "##k for #r" + gain[i] + " NX#k each#l";
    }
    cm.sendSimple(text);
}

 function action(mode, type, selection) {
    if (mode == 1) {
        status++;
	} else if (mode == 0) {
		status--;
    } else {
        cm.dispose();
        return;
    }
    if (status == 0) {
		if (mode == 1) {
			sel = selection;
			cm.sendGetNumber("How many would you like to trade?", 1, 1, cm.getPlayer().getItemQuantity(item[sel], false));
		} else if (mode == 0) {
			cm.sendOk("Really? Well come back whenever you wish to trade.");
			cm.dispose();
		}
	} else if (status == 1) {
		multiplier = selection;
		total = multiplier * gain[sel];
        cm.sendYesNo("Are you sure you'd like to trade #r" + mult + " #i" + item[sel] + "# #b#v" + item[sel] + "##k for #r" + total + "#k NX?");
    } else if (status == 2) {
        if (cm.haveItem(item[sel], multiplier)) { // Redundant I know but whatever
            cm.gainItem(item[sel], -multiplier);
            cm.getPlayer().modifyCSPoints(1, total, false);
            cm.sendOk("Enjoy your reward");
        } else {
            cm.sendOk("Please make sure you have #i" + item[sel] + "# #v" + item[sel] + "#.");
        }
        cm.dispose();
    }
}
 
Upvote 0
Initiate Mage
Joined
Feb 14, 2011
Messages
58
Reaction score
2
here you are...

PHP:
var status = -1;
var sel;
var multiplier;
var total;
var item = [4032522, 4032523, 4032524];
var gain = [100, 500, 1000];

function start() {
    var text = "insert beginning text here"; // modify to your liking. This will appear before the selections
    for (var i = 0; i < item.length; i++) {
        text += "#b\r\n#l" + i + "##i" + item[i] + "# #v" + item[i] + "##k for #r" + gain[i] + " nx#k each#l";
    }
    cm.sendsimple(text);
}

 function action(mode, type, selection) {
    if (mode == 1) {
        status++;
	} else if (mode == 0) {
		status--;
    } else {
        cm.dispose();
        return;
    }
    if (status == 0) {
		if (mode == 1) {
			sel = selection;
			cm.sendgetnumber("how many would you like to trade?", 1, 1, cm.getplayer().getitemquantity(item[sel], false));
		} else if (mode == 0) {
			cm.sendok("really? Well come back whenever you wish to trade.");
			cm.dispose();
		}
	} else if (status == 1) {
		multiplier = selection;
		total = multiplier * gain[sel];
        cm.sendyesno("are you sure you'd like to trade #r" + mult + " #i" + item[sel] + "# #b#v" + item[sel] + "##k for #r" + total + "#k nx?");
    } else if (status == 2) {
        if (cm.haveitem(item[sel], multiplier)) { // redundant i know but whatever
            cm.gainitem(item[sel], -multiplier);
            cm.getplayer().modifycspoints(1, total, false);
            cm.sendok("enjoy your reward");
        } else {
            cm.sendok("please make sure you have #i" + item[sel] + "# #v" + item[sel] + "#.");
        }
        cm.dispose();
    }
}

It doesnt work the qunatity box pops up but when i try and redeem any amount it doesnt work anymore
 
Last edited:
Upvote 0
Back
Top