• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Add-On] Learning NPC scripts (beginner's guide)

Status
Not open for further replies.
Junior Spellweaver
Joined
Feb 8, 2009
Messages
128
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

ARGHHH !

whats wrong with it ???

PHP:
/* 
Oh , look Staars :D *****
*/
var status = 0;

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

function action(mode, type, selection) {
	if (mode == -1) {
		cm.sendOk("duck You :D");
		cm.dispose();
	} else {
		if (status >= 0 && mode == 0) {
			cm.sendOk("FUUUUUCK YOU :D    8==========>");
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendYesNo("Stop clicking ... FCK YOU !");
		} else if (status == 1) {
			cm.sendNext("You suck ... same like your mom!");
		} else if (status == 2) {
			cm.warp(3, 0);
			cm.sendNext("You crappy noob fail @ coding ! so ... duck YOU !");
			cm.dispose();
		}
	}
}

How comes it always says "duck You" O= ?!
Where can i change this ?
HELP PLZZZzzzzZZZ !!!
 
Initiate Mage
Joined
Apr 24, 2009
Messages
1
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

You should be able to figure it out. Read the damn code.
 
Experienced Elementalist
Joined
Mar 25, 2009
Messages
204
Reaction score
2
Re: [Tut] Learning NPC scripts (beginner's guide)

how'd i add a pic of a mob inside my NPC , like for skillz #s[skillid]# . is it #m[mobid]# for mobs then ?
 
Newbie Spellweaver
Joined
Aug 7, 2008
Messages
5
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

ok this is the nubist Q of the day im having issues DL C++ and or C# my comp is gay and it wont DL, is there another program i can use to code
 
Newbie Spellweaver
Joined
Apr 9, 2008
Messages
60
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Great guide. Used this about a week ago and it helped me out a lot.
 
Experienced Elementalist
Joined
Mar 25, 2009
Messages
204
Reaction score
2
Re: [Tut] Learning NPC scripts (beginner's guide)

ok this is the nubist Q of the day im having issues DL C++ and or C# my comp is gay and it wont DL, is there another program i can use to code

Notepad :eek:?
 
Initiate Mage
Joined
Mar 29, 2009
Messages
3
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

ok this is the nubist Q of the day im having issues DL C++ and or C# my comp is gay and it wont DL, is there another program i can use to code

A good program to use that's better then notepad is, Notepad++, I would recommend that.
 
Newbie Spellweaver
Joined
Jul 11, 2008
Messages
10
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

after you make your script how do you add it to ur server?
 
Initiate Mage
Joined
Feb 6, 2009
Messages
3
Reaction score
0
Would this work?

Would my script work?

/* Mikaela's Custom Wedding Script #1 */

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("See you later");
cm.dispose();
return;
}

if (mode == 1) {
status++;
}
else {
status--;
}

if (status == 1) {
cm.sendNext("Hello, I'm the head organizer of NhatMs Weddings");

}
else if (status == 0) {
cm.sendYesNo("Are YOU getting married?!");
}
else if (status == 0) {
cm.sendOk("Fantastic! Have your mate talk to me, too, to meet you in the dressing room");
cm.warp([680000100], [0]);
cm.dispose();
}
else if (status == 1)
cm.sendOk("I know how you feel...");
cm.dispose();
}
}
}
Just making sure :/
 
Newbie Spellweaver
Joined
Jan 3, 2009
Messages
25
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

arigatou thank you this has helped me alot in my past projects
 
Newbie Spellweaver
Joined
May 2, 2009
Messages
6
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

get31720, you may want to add that comments can be put in two ways:

Code:
//Like this...

or:

Code:
/* Like
This
.
.
.
*/
 
Newbie Spellweaver
Joined
Sep 20, 2007
Messages
41
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Great tut, especially simple because I already know actionScript and a bit of javaScript already. +thank'd.
 
Newbie Spellweaver
Joined
Jan 24, 2009
Messages
7
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Cool tutorial, helped me lots.

But, I have a problem with this script.

Code:
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var status = 0;

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

function action(mode, type, selection) {
    if (mode == -1) {
        cm.sendOk("Now I'm going emo 'cuz you want talk to me D:");
        cm.dispose();
    } else {
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
	cm.sendNext("Hello! My name is Duey and TEST NPC made by #d Jurkey");
	} else if (status == 1) {
	cm.sendGetText("What's your name?");
	} else if (status == 2) {
	cm.sendNext("Hello #b" + cm.getText() + "#k! Glad to meet you!");
        } else if (status == 3) {
            cm.sendNext("Do you want 100 NX Cash and 1 million mesos? It only works if you are SuperGM");
        } else if (status == 4) {
            if (cm.getJob().equals(net.sf.odinms.client.MapleJob. SUPERGM)) {
                cm.gainNX(100);
                cm.gainMeso(10000);
                cm.sendOk("Enjoy and goodbye!");
                cm.dispose();
            }
        }
    }
}

What's wrong with it?
 
Initiate Mage
Joined
Dec 25, 2008
Messages
3
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Thanks for this guild. I can learn much more from here. :)
 
Newbie Spellweaver
Joined
Feb 19, 2009
Messages
16
Reaction score
1
Re: [Tut] Learning NPC scripts (beginner's guide)

I'm using the pack rev 107 and I was asking if someone can tell me which commend is use to make a NPC spawn a monster...

cm.spawnMonster doesn't exist so.....HELP XD
 
Newbie Spellweaver
Joined
Jan 2, 2009
Messages
9
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Hi this is my first post ever on RageZone, but I
 
Newbie Spellweaver
Joined
Aug 12, 2009
Messages
12
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Hello, thanks for this guide Angel! It is very useful.

Um, I know this is a very simple script, but I have been having trouble setting up a server (RuntimeExceptions and whatnot), so I can't really test this. Is it set up correctly? (Particularly the (status == 3) part.)

PHP:
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("See you around!");   
            cm.dispose();   
            return;   
        }   
          
        if (mode == 1) {  
            status++;  
        }      
        else {  
            status--;  
        }  
          
        if (status == 0) { 
            cm.sendNext("Hello, welcome to RandompeepMS!");
            cm.dispose();
        }
	else if (status == 1) {
            cm.sendNext("How goes the hunting?");
            cm.dispose();
            }
        }
        else if (status == 2) {
            cm.sendSimple("Do you need mesos? \r\n#L0#Yes, I'm broke and need some to start!#l\r\n#L1#No, but can I have some anyways?#l\r\n#L2#No, thank you.#l");
            }
        }
        else if (status == 3) {
            if (selection == 0) {
                if (cm.getmeso() <= 1000) {
                    cm.gainmeso([500000]);
                    cm.sendOk("Wow, you really do need mesos. Well, I do not have much myself, but I hope it'll do.")
                    cm.dispose();
                }
                else {
                    cm.sendOk("No, you aren't. Don't rip me off!");
                    cm.dispose();
                }
            else if (selection == 1) {
                if (cm.getmeso() <= 1000000) {
                    cm.gainmeso([100000]);
                    cm.sendOk("Well, you don't really need it, but... have a little anyways.");
                    cm.dispose();
                }
                else {
                    cm.sendOk("You don't have enough already? Stop leeching off my mesos; you have more than me now!");
                    cm.dispose();
                }
            else if (selection == 2) {
                cm.sendOk("You're an honest one. Unfortunately I don't have anything else to give you. Maybe some other day. (When I figure out how to code adding fame/karma!");
                cm.dispose();
                }
            }
        }
    }
}

Thanks for answering!

Note: I have since figured out how to give fame. But, does it work on a server with karma instead?

Also, could you check this:
PHP:
            else if (selection == 2) {
                cm.sendOk("You're an honest one. Unfortunately I don't have anything else to give you. Maybe some other day.");
                cm.dispose();
                    if (cm.getFame() <= 25) {
                        cm.gainFame([1]);
                    }
                }
            }
        }
    }
}
It's just the last part of the above script. Thank you for checking and (hopefully) answering the question!

Also, how do you use these? How do you determine which NPC gets the script?
 
Last edited:
Newbie Spellweaver
Joined
Apr 19, 2009
Messages
6
Reaction score
0
Re: [Tut] Learning NPC scripts (beginner's guide)

Yo man,

I'm trying to edit my prize giver so my players can get cool items, It used to work just fine but now it wont work? can you correct what i did wrong Please and thank you!:D:

/*Yellow Balloon
*/
/*Made By Saber
*/
var status = 0;
var l = "Welcome to the Custom Event ITEM Shop!, choose an item you'd wish to trade in for \r\n\n#fUI/UIWindow.img/QuestIcon/3/0#\r\n\n#L0#1#i1002140##t1002140# ~ 200 Tickets#l\r\n\n#L1# 1#i1042003##t1042003# ~ 400 tickets#l\r\n\n#L2# 1#i1062007##t1062007# ~ 1500 tickets#l\r\n\n#L3# 1#i1322013##t1322013# ~ 1500 tickets#l\r\n\n#L4# 1#i1442023##t1442023# ~ 50 tickets#l\r\n\n#L5# 1#i1012106##t1012106# ~ 700 tickets#l\r\n\n#L6# 1#i1012086##t1012086# ~ 420 tickets#l\r\n\n#L7# 1#i1012076##t1012076# ~ 580 tickets#l\r\n\n#L8# 1#i1012077##t1012077# ~ 20 tickets#l\r\n\n#L9# 1#i1452060##t1452060# ~ 900 tickets#l";
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;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("Do you have any #i5220001# Event Tickets? If You Do You Can Trade It For Some Nice Items!");
}else if(status == 1){
cm.sendSimple(l+r);
}else if(status == 2){
if(!cm.haveItem(5220001)){
cm.sendOk("Come Back When You Have Some Event Tickets");
cm.dispose();
}else if(selection >= 0 && selection <= 0 && !cm.haveItem(5220001,200)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 1 && selection <= 1 && !cm.haveItem(5220001,400)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 2 && selection <= 2 && !cm.haveItem(5220001,1500)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 3 && selection <= 3 && !cm.haveItem(5220001,1500)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 4 && selection <= 4 && !cm.haveItem(5220001,50)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 5 && selection <= 5 && !cm.haveItem(5220001,700)){
cm.sendOk("Come Back When You Obtain A few Event Tickets");
cm.dispose();
}else if(selection >= 6 && selection <= 6 && !cm.haveItem(5220001,420)){
cm.sendOk("Come Back When You Obtain A few Events Tickets");
cm.dispose();
}else if(selection >= 7 && selection <= 7 && !cm.haveItem(5220001,580)){
cm.sendOk("Come Back When You Obtain A few Events Tickets");
cm.dispose();
}else if(selection >= 8 && selection <= 8 && !cm.haveItem(5220001,20)){
cm.sendOk("Come Back When You Obtain A few Events Tickets");
cm.dispose();
}else if(selection >= 9 && selection <= 9 && !cm.haveItem(5220001,900)){
cm.sendOk("Come Back When You Obtain A few Events Tickets");
cm.dispose();
}else{
if(selection == 0){
cm.gainItem(1002140,1);
cm.gainItem(5220001,-200);
}else if(selection == 1){
cm.gainItem(1042003,1);
cm.gainItem(5220001,-400);
}else if(selection == 2){
cm.gainItem(1062007,1);
cm.gainItem(5220001,-1500);
}else if(selection == 3){
cm.gainItem(1322013,1);
cm.gainItem(5220001,-1500);
}else if(selection == 4){
cm.gainItem(1442023,1);
cm.gainItem(5220001,-50);
}else if(selection == 5){
cm.gainItem(1012106,1);
cm.gainItem(5220001,-700);
}else if(selection == 6){
cm.gainItem(1012086,1);
cm.gainItem(5220001,-420);
}else if(selection == 7){
cm.gainItem(1012076,1);
cm.gainItem(5220001,-580);
}else if(selection == 8){
cm.gainItem(1012077,1);
cm.gainItem(5220001,-20);
}else if(selection == 9){
cm.gainItem(1452060,1);
cm.gainItem(5220001,-900);
}
cm.sendOk("There you go, Hope You Enjoy It");
cm.dispose();
}
}
}
}
 
Last edited:
Status
Not open for further replies.
Back
Top