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!

[Release] Item Trader NPC

Newbie Spellweaver
Joined
Feb 21, 2011
Messages
44
Reaction score
31
Hey guys, first release.
This is an easy customizible NPC, that you can change yourself. Say you want to change the item traded from maple leaves to Golden Maple Leaves. Just change the variable at the top, and at the bottom, and on the selections. You can easily edit the items that are given to the character by changing the itemID and name. Enjoy!

PHP:
/**
OdinMS Javascript
NPC: Spiegelmann

**/


var status;
var leafs;
var itemID;
var itemName;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    status++;
    if(mode != 1){
        cm.dispose();
        return;
    }
    if(status == 0){
      cm.sendNext("Hello, you got any Maple Leaves?");
	  } else if (status == 1) {
	  cm.sendSimple("You can obtain Maple Leaves from killing any monster. Anyways, you can trade your Maple Leaves here for items. By the way, the Maple Leaves look like this: #v4001126. \r\n\r\n#L0##e#bCrystal Ilbi Forging Manual#l\r\n#L1#Crystal Leaf Earrings Forging Manual#l\r\n#L2#Facestompers Forging Manual#l\r\n#L3#Black Phoenix Shield Forging Manual#l\r\n#L4#Neva Forging Manual#l\r\n#L5#Stormcasters Forging Manual#l\r\n#L6#Sirius Cloak Forging Manual#l\r\n#L7#Tiger's Fang Forging Manual#l\r\n#L8#Ilbi#l");
	  } else if (status == 2) {
	  
	  if (selection == 0) {
	  leafs = 250;
	  itemID = 4031912;
	  itemName = "Crystal Ilbi Forging Manual";
	  
	  } else if (selection == 1) {
	  leafs = 200;
	  itemID = 4031825;
	  itemName = "Crystal Leaf Earring Forging Manual";
	  
	  } else if (selection == 2) {
	  leafs = 325;
	  itemID = 4031911;
	  itemName = "Facestompers Forging Manual";
	  
	  } else if (selection == 3) {
	  leafs = 175;
	  itemID = 4031829;
	  itemName = "Black Phoenix Shield Forging Manual";
	  
	  } else if (selection == 4) {
	  leafs = 200;
	  itemID = 4031908;
	  itemName = "Neva Forging Manual";
	  
	  } else if (selection == 5) {
	  leafs = 325;
	  itemID = 4031824;
	  itemName = "Stormcasters Forging Manual";
	  
	  } else if (selection == 6) {
	  leafs = 175;
	  itemID = 4031827;
	  itemName = "Sirius Cloak Forging Manual";
	  
	  } else if (selection == 7) {
	  leafs = 225;
	  itemID = 4031907;
	  itemName = "Tiger's Fang Forging Manual";
	  
	  } else if (selection == 8) {
	  leafs = 150;
	  itemID = 2070006;
	  itemName = "Ilbi";
	  
	  }
	  
	  cm.sendYesNo("Are you sure you want to get the " + itemName + "? It will cost you #b" + leafs + " #kMaple Leaves.");
	  
	  } else if (mode == 1) {
	  if (!cm.haveItem(4001126,leafs)){
	 cm.sendOk("You don't have the required #b" + leafs + " Maple Leaves. #kVote more, and you will get enough eventually.");
	  cm.dispose();
	  }else{
	  
	   cm.gainItem(4001126,-leafs);
	  cm.gainItem(itemID,1);
	  
	  
	  cm.sendOk("Enjoy your #b" + itemName + "! #kRemember to vote more often to get more of these exclusive deals!");
	  cm.dispose();
	  
	  }
	  }
	  }
 
Last edited:
Skilled Illusionist
Joined
Dec 16, 2010
Messages
304
Reaction score
164
Not bad. First release?

I got bored so I decided to make one that I thought was more user-friendly and all around cooler :O Not tested, and I experimented with some # codes, so I would appreciate somebody looking this over. Anyways, here it is :p
PHP:
/**
 * How to Edit:
 * Put the item ID you want to use in place of '4001126' for the item players need to trade in.
 * Put the item IDs of the prizes in the first section of the item array. Where you see '4031912, 4031825, etc'.
 * Put the amount of the requiredItem the player needs for the CORRESPONDING item in the second part of the item array. Where you see '250, 200, etc'.
 * Corresponding means: Match up the item ID to the amount of requiredItem needed. In this script, the player needs 250 requiredItem for the '4031912' item.
 */
var status = 0;
var requiredItem = 4001126;
var item = [[4031912, 4031825, 4031911, 4031829, 4031908, 4031824, 4031827, 4031907, 2070006], [250, 200, 325, 175, 200, 325, 175, 225, 150]];
var sel;

function start(){
	cm.sendNext("Hello! Do you have any #r#t"+ requiredItem +"##k? If you do, I can trade you some items for them!");
}

function action(m,t,s){
	status++;
	if(m != 1){
		cm.dispose();
		return;
	}
	if(status == 1){
		if(!cm.haveItem(requiredItem)){ // SORRY, I had this as item[0] =/
			cm.sendOk("You don't have any #r#t"+ requiredItem +"##k!");
			cm.dispose();
		} else {
			var talk = "Which Item would you like to buy?#b";
			for(var i = 0; i < item[0].length; talk += "\r\n\t#L"+ i +"##t"+ item[0][i] +"##l", i++);
			cm.sendSimple(talk);
		}
	} else if (status == 2){
		sel = s;
		cm.sendYesNo("Would you like to buy 1 #b#t"+ item[0][s] +"##kdItem for #r"+ item[1][s] +" #t"+ requiredItem +"#?");
	} else if (status == 3){
		if(cm.haveItem(requiredItem, item[1][sel])){
			cm.sendOk("Enjoy your #b#t" + item[0][sel] + "##k! Remember to vote more often to get more of these exclusive deals!");
			cm.gainItem(item[0][sel]);
			cm.gainItem(requiredItem, -item[1][sel]);
		} else {
			var percent = Math.ceil(cm.itemQuantity(requiredItem) / item[1][sel]); // removed the +100, as the #B # reads decimals x_x
			cm.sendOk("You only have #b#c"+ requiredItem +"# #t"+ requiredItem +"##k. You need #r"+ item[1][sel] +" #t"+ requiredItem +"##k to buy a #b#t"+ item[0][sel] +"##k! \r\n\r\n#ePercent of #b#t"+ requiredItem +"#'s#k collected (rounded by the 10%): \r\n#B"+ percent +"#");
		}
        cm.dispose(); // forgot this in the first post, sorry x_x
	}
}
 
Last edited:
Newbie Spellweaver
Joined
Feb 21, 2011
Messages
44
Reaction score
31
Not bad. First release?

I got bored so I decided to make one that I thought was more user-friendly and all around cooler :O Not tested, and I experimented with some # codes, so I would appreciate somebody looking this over. Anyways, here it is :p
PHP:
/**
 * How to Edit:
 * Put the item ID you want to use in place of '4001126' for the item players need to trade in.
 * Put the item IDs of the prizes in the first section of the item array. Where you see '4031912, 4031825, etc'.
 * Put the amount of the requiredItem the player needs for the CORRESPONDING item in the second part of the item array. Where you see '250, 200, etc'.
 * Corresponding means: Match up the item ID to the amount of requiredItem needed. In this script, the player needs 250 requiredItem for the '4031912' item.
 */
var status = 0;
requiredItem = 4001126;
item = [[4031912, 4031825, 4031911, 4031829, 4031908, 4031824, 4031827, 4031907, 2070006], [250, 200, 325, 175, 200, 325, 175, 225, 150]];
var sel;

function start(){
	cm.sendNext("Hello! Do you have any #r#t"+ requiredItem +"##k? If you do, I can trade you some items for them!");
}

function action(m,t,s){
	status++;
	if(m != 1){
		cm.dispose();
		return;
	}
	if(status == 1){
		if(!cm.haveItem(item[0])){
			cm.sendOk("You don't have any #r#t"+ requiredItem +"##k!");
			cm.dispose();
		} else {
			var talk = "Which Item would you like to buy?#b";
			for(var i = 0; i < item[0].length; talk += "\r\n\t#L"+ i +"##t"+ item[0][i] +"##l", i++);
			cm.sendSimple(talk);
		}
	} else if (status == 2){
		sel = s;
		cm.sendYesNo("Would you like to buy 1 #b#t"+ item[0][s] +"##kdItem for #r"+ item[1][s] +" #t"+ requiredItem +"#?");
	} else if (status == 3){
		if(cm.haveItem(requiredItem, item[1][sel])){
			cm.sendOk("Enjoy your #b#t" + item[0][sel] + "##k! Remember to vote more often to get more of these exclusive deals!");
			cm.gainItem(item[0][sel]);
			cm.gainItem(requiredItem, -item[1][sel]);
		} else {
			var percent = Math.ceil(cm.itemQuantity(requiredItem) / item[1][sel] + 100);
			cm.sendOk("You only have #b#c"+ requiredItem +"# #t"+ requiredItem +"##k. You need #r"+ item[1][sel] +" #t"+ requiredItem +"##k to buy a #b#t"+ item[0][sel] +"##k! \r\n\r\n#ePercent of #b#t"+ requiredItem +"#'s#k collected: \r\n#B"+ percent +"#");
		}
	}
}

Wow, nice, I'm impressed. You used way less characters than me. I'm still kind of new to this though, haha.
 
Newbie Spellweaver
Joined
Feb 21, 2011
Messages
44
Reaction score
31
Can be stop releasing these crappy npcs? Just keep them for yourself. Kthnx

I just released something that I made. Is there something wrong with that? There is no rule about releasing bad stuff, is there?
 
Skilled Illusionist
Joined
Dec 16, 2010
Messages
304
Reaction score
164
I just released something that I made. Is there something wrong with that? There is no rule about releasing bad stuff, is there?
If there were, Kevin couldn't have released MoopleDev :p ROFL, kidding buddy.

Can be stop releasing these crappy npcs? Just keep them for yourself. Kthnx
I'm gonna release one later just because you posted this ;)
 
Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
Chris, i will kill you. And you better release it in the help section. Yours are always corrupt.

And release something that is worth it.
 
Junior Spellweaver
Joined
Feb 8, 2011
Messages
121
Reaction score
17
Yeah Kev, haha. Youll scare off all the people trying to learn, then we'll be left with leechers.
 
Back
Top