[Add-On]Some Useful Npc

Junior Spellweaver
Joined
Oct 12, 2010
Messages
152
Reaction score
39
Hey there , Here is some useful npc i coded. I am glad to sharing to everyone.Who are needed those npc.Hope this can help you fast growing your server/Maybe helped xD
Tetris system
2050015.js
PHP:
*/Credit : Wingx
*/Edit : Bryan
*/For : Kinostory
var status = 0;
var map = Array(240010501);

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4030002##k? Or do you want to trade in my #b#v4030002##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4030002##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4030002##k!#l");
        } else if (status == 1) {
            if (selection == 1) {
                if(cm.haveItem(4030002)) {
                    cm.gainMeso(2000000000);
                    cm.gainItem(4030002,-1); 
                    cm.sendOk("Thank you for your mesos!");
                } else {
                    cm.sendOk("Sorry, you don't have a #b#v4030002##k!");
                }
                cm.dispose();
            } else if (status == 2) {
            } else if (selection == 2) {
                if(cm.getMeso() >= 2000000000) {
                    cm.gainMeso(-2000000000);
                    cm.gainItem(4030002,1);
                    cm.sendOk("Thank you for your item!");
                } else {
                    cm.sendOk("Sorry, you don't have enough mesos!");
                }
                cm.dispose();
            }
            else{
                cm.sendOk("All right. Come back later");
            }
        }
    }
}

Flask System
2050015.js
PHP:
*/Credit : Wingx
*/For : WingMs
var status = 0;
var map = Array(240010501);

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000356##k? Or do you want to trade in my #b#v4000356##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000356##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000356##k!#l");
        } else if (status == 1) {
            if (selection == 1) {
                if(cm.haveItem(4000356)) {
                    cm.gainMeso(2000000000);
                    cm.gainItem(4000356,-1); 
                    cm.sendOk("Thank you for your mesos!");
                } else {
                    cm.sendOk("Sorry, you don't have a #b#v4000356##k!");
                }
                cm.dispose();
            } else if (status == 2) {
            } else if (selection == 2) {
                if(cm.getMeso() >= 2000000000) {
                    cm.gainMeso(-2000000000);
                    cm.gainItem(4000356,1);
                    cm.sendOk("Thank you for your item!");
                } else {
                    cm.sendOk("Sorry, you don't have enough mesos!");
                }
                cm.dispose();
            }
            else{
                cm.sendOk("All right. Come back later");
            }
        }
    }
}

Carrot System
2050015.js
PHP:
*/Credit : Wingx
*/For : WingMs
var status = 0;
var map = Array(240010501);

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
        } else if (status == 1) {
            if (selection == 1) {
                if(cm.haveItem(4000325)) {
                    cm.gainMeso(2000000000);
                    cm.gainItem(4000325,-1); 
                    cm.sendOk("Thank you for your mesos!");
                } else {
                    cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
                }
                cm.dispose();
            } else if (status == 2) {
            } else if (selection == 2) {
                if(cm.getMeso() >= 2000000000) {
                    cm.gainMeso(-2000000000);
                    cm.gainItem(4000325,1);
                    cm.sendOk("Thank you for your item!");
                } else {
                    cm.sendOk("Sorry, you don't have enough mesos!");
                }
                cm.dispose();
            }
            else{
                cm.sendOk("All right. Come back later");
            }
        }
    }
}

Maple leaf system
2050015.js
PHP:
*/Credit : Wingx
*/For : XeonMs 
var status = 0;
var map = Array(240010501);

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4001126##k? Or do you want to trade in my #b#v4001126##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4001126##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4001126##k!#l");
        } else if (status == 1) {
            if (selection == 1) {
                if(cm.haveItem(4001126)) {
                    cm.gainMeso(2000000000);
                    cm.gainItem(4001126,-1); 
                    cm.sendOk("Thank you for your mesos!");
                } else {
                    cm.sendOk("Sorry, you don't have a #b#v4001126##k!");
                }
                cm.dispose();
            } else if (status == 2) {
            } else if (selection == 2) {
                if(cm.getMeso() >= 2000000000) {
                    cm.gainMeso(-2000000000);
                    cm.gainItem(4001126,1);
                    cm.sendOk("Thank you for your item!");
                } else {
                    cm.sendOk("Sorry, you don't have enough mesos!");
                }
                cm.dispose();
            }
            else{
                cm.sendOk("All right. Come back later");
            }
        }
    }
}

Anyway ,
Please don't worry it's been tested and worked , Hope it helped you :D: Please click thank if helped or not , I am ok i just wanna share to everyone who needed those npc
 
Last edited by a moderator:
Re: Some Useful Npc

It's... Meh.

1. Most people who code in Java should be able to do this themselves. If they can't, they shouldn't be running a server.

2. It's the same script over an over, just changing the Item ID...

3. Even if you put this in, it's just a converter. It doesn't actually integrate the system into everything.

4. The way this is coded and set up is messy. You follow "if (status == 1)" with "else if (selection == 1)" which you then follow with "else if (status == 2)" and finally "else if (selection == 2)".
It's just... not... >.<
 
Re: Some Useful Npc

Please click thank if helped or not , I am ok i just wanna share to everyone who needed those npc

You also can don't click thanks it's fine with me , because i just share for everyone
 
Re: Some Useful Npc

Guys, guys.. calm down. This is a release, like everything else. The purpose of this is to help and let the releaser learn from his/her mistakes.

-

Thanks :D.
 
Re: Some Useful Npc

I don't believe status is even needed for a script like this.
You could have done it like this:
PHP:
/* Credit: Wingx
   For: WingMS */
function start(){
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(m,t,s){
	if(m != 1){
		cm.dispose();
		return;
	} else {
		if(s == 0){
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
				cm.dispose();  // you forgot this O_o
			} else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
				cm.dispose(); // you forgot this O_o
			}
		} else if(s == 1){
			if(cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
				cm.dispose(); // you forgot this O_o
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
				cm.dispose(); // you forgot this O_o
			}
		} else {
			cm.dispose();
		}
	}
}

Anyways, good first release, I suppose, although there are COUNTLESS threads with a similar script.
 
Last edited:
Re: Some Useful Npc

I don't believe status is even needed for a script like this. Also you forgot plenty of cm.dispose()'s. You said your script is tested and working?... I find that sort of hard to believe O_o Although I'm not sure if leaving out a cm.dispose or two will bug the script or not.
You could have done it like this:
PHP:
/* Credit: Wingx
   For: WingMS */
function start(){
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(m,t,s){
	if(m != 1){
		cm.dispose();
		return;
	} else {
		if(s == 0){
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
				cm.dispose();  // you forgot this O_o
			} else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
				cm.dispose(); // you forgot this O_o
			}
		} else if(s == 1){
			if(cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
				cm.dispose(); // you forgot this O_o
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
				cm.dispose(); // you forgot this O_o
			}
		} else {
			cm.dispose();
		}
	}
}

Anyways, good first release, I suppose, although there are COUNTLESS threads with a similar script.

Only need 1 dispose.
PHP:
function start() {
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(mode, type, selection){
	if (mode == 1) {
		if (selection == 0) {
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
			} 
			else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
			}
		}
		else if (selection == 1) {
			if (cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
            }
			else {
                cm.sendOk("Sorry, you don't have enough mesos!");
			}
		}
	}
	cm.dispose();
}
 
Re: Some Useful Npc

Only need 1 dispose.
PHP:
function start() {
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(mode, type, selection){
	if (mode == 1) {
		if (selection == 0) {
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
			} 
			else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
			}
		}
		else if (selection == 1) {
			if (cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
            }
			else {
                cm.sendOk("Sorry, you don't have enough mesos!");
			}
		}
	}
	cm.dispose();
}

You can also put the dispose up top so it doesn't look weird being by itself :p

PHP:
function start() {
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(mode, type, selection){
	cm.dispose();
	if (mode == 1) {
		if (selection == 0) {
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
			} else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
			}
		} else if (selection == 1) {
			if (cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
			}
		}
	}
}

On Topic: I'm sorry man, but if you're going to just release the same exact NPC over and over with literally only the required item being changed, I'm going to have to close the releases... Try to be a bit more innovative.
 
Re: Some Useful Npc

You can also put the dispose up top so it doesn't look weird being by itself :p

PHP:
function start() {
	cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(mode, type, selection){
	cm.dispose();
	if (mode == 1) {
		if (selection == 0) {
			if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
			} else {
				cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
			}
		} else if (selection == 1) {
			if (cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
			}
		}
	}
}

On Topic: I'm sorry man, but if you're going to just release the same exact NPC over and over with literally only the required item being changed, I'm going to have to close the releases... Try to be a bit more innovative.

The dispose is an outcast, he plays by his own rules. He comes last becaues he chooses to and he isnt a problem in the system! He is alone, only one in small scripts such as these. Bigger scripts with higher populations may have more then one dispose, but dont come across them or they will end you!
 
Re: Some Useful Npc

Just woke up, missed the "only 1 dispose needed" thing. sue me :P

Missed what "only 1 dispose needed" thing? Why offer an excuse? You need not explain anything to anyone when you are real about your talent in terms of programming.
 
Re: Some Useful Npc

Missed what "only 1 dispose needed" thing? Why offer an excuse? You need not explain anything to anyone when you are real about your talent in terms of programming.
When you say it like that, you make me sound like a Douchebag O_o
I'm honest about my programming. I've asked Shawn and others countless things for NPC scripting and I never admit to knowing things I don't.
For instance, I did not know I could put cm.dispose() before if(mode == 1){ O_o, but yes, I was aware you could put cm.dispose() after you closed off the mode bracket.

Btw, I apologize for saying he didn't put cm.dispose()'s in the right place. I skimmed the script and mainly just copied over the text, and I didn't notice that he actually had them in there. O_o
 
Re: Some Useful Npc

When you say it like that, you make me sound like a Douchebag O_o
I'm honest about my programming. I've asked Shawn and others countless things for NPC scripting and I never admit to knowing things I don't.
For instance, I did not know I could put cm.dispose() before if(mode == 1){ O_o, but yes, I was aware you could put cm.dispose() after you closed off the mode bracket.

Btw, I apologize for saying he didn't put cm.dispose()'s in the right place. I skimmed the script and mainly just copied over the text, and I didn't notice that he actually had them in there. O_o

Well my main intention was to point out that having an excuse is a douche move, thats all. No need for you to apologize still. :laugh:
 
Re: Some Useful Npc

Oh my :O:
There are so many different of type code
Like this have m,t,s
PHP:
/* Credit: Wingx
   For: WingMS */
function start(){
    cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(m,t,s){
    if(m != 1){
        cm.dispose();
        return;
    } else {
        if(s == 0){
            if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
                cm.dispose();  // you forgot this O_o
            } else {
                cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
                cm.dispose(); // you forgot this O_o
            }
        } else if(s == 1){
            if(cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
                cm.dispose(); // you forgot this O_o
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
                cm.dispose(); // you forgot this O_o
            }
        } else {
            cm.dispose();
        }
    }
}

and like this short once , but look more easy :lol:
PHP:
function start() {
    cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L1# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n\#L2# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}
function action(mode, type, selection){
    cm.dispose();
    if (mode == 1) {
        if (selection == 0) {
            if(cm.haveItem(4000325)) {
                cm.gainMeso(2000000000);
                cm.gainItem(4000325,-1); 
                cm.sendOk("Thank you for your mesos!");
            } else {
                cm.sendOk("Sorry, you don't have a #b#v4000325##k!");
            }
        } else if (selection == 1) {
            if (cm.getMeso() >= 2000000000) {
                cm.gainMeso(-2000000000);
                cm.gainItem(4000325,1);
                cm.sendOk("Thank you for your item!");
            } else {
                cm.sendOk("Sorry, you don't have enough mesos!");
            }
        }
    }
}

Thanks all ,for post different code, but have a little weird by me :$: Anyway , i need to learn more :D:
 
Re: Some Useful Npc

Sorry guys for bumping just had to say. OMFG all tried to make a better and shorter one but no one noticed the error :P figure that out ;)
 
Re: Some Useful Npc

Sorry guys for bumping just had to say. OMFG all tried to make a better and shorter one but no one noticed the error :P figure that out ;)

blah blah, selection is only 1 and 2, and the scripts ask for 0 and 1. big deal...

My version:

PHP:
homo = [cm.haveItem(4000325), cm.getMeso() >= 2000000000, cm.gainMeso(2000000000), cm.gainMeso(-2000000000)];

function start(){
    cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L0# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n#L1# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}

function action(mode, type, selection){
    cm.dispose();
    if (mode > 0) {
        if(homo[selection]) {
		    homo[selection + 2];
            cm.gainItem(4000325, -1 + (2 * selection)); 
            cm.sendOk("Thank you for your " + (selection == 0 ? "item" : "mesos") + "!");
        } else
            cm.sendOk("Sorry, you don't have " + (selection == 0 ? "a #b#v4000325##k" : "enough mesos!"));
    }
}
 
Last edited:
Re: Some Useful Npc

blah blah, selection is only 1 and 2, and the scripts ask for 0 and 1. big deal...

My version:

PHP:
homo = [cm.haveItem(4000325), cm.getMeso() >= 2000000000, cm.gainMeso(2000000000), cm.gainMeso(-2000000000)];

function start(){
    cm.sendSimple("Hello, I am the Meso to Item converter. Do you want to trade in 2 billion mesos for a #b#v4000325##k? Or do you want to trade in my #b#v4000325##k for 2 billion mesos?\r\n#L0# I would like to trade my #b#v4000325##k for 2 billion mesos!#l\r\n#L1# I would like to exchange 2 billion mesos for a #b#v4000325##k!#l");
}

function action(mode, type, selection){
    cm.dispose();
    if (mode > 0) {
        if(homo[selection]) {
		    homo[selection + 2];
            cm.gainItem(4000325, -1 + (2 * selection)); 
            cm.sendOk("Thank you for your " + (selection == 0 ? "item" : "mesos") + "!");
        } else
            cm.sendOk("Sorry, you don't have " + (selection == 0 ? "a #b#v4000325##k" : "enough mesos!");
    }
}

You're missing the closing ellipsis with your last sendOk, not like it's a big deal :/:

cm.sendOk("Sorry, you don't have " + (selection == 0 ? "a #b#v4000325##k" : "enough mesos!"));
 
Last edited:
You all notice these random things, yet no one noticed that

#b#v<id>##k

the #b and #k are completely useless. o-o
 
Back