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!

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

Status
Not open for further replies.
Banned
Banned
Joined
Sep 21, 2008
Messages
68
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

The hell is this crap?
 
Initiate Mage
Joined
Dec 10, 2008
Messages
4
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Wow...

Thank you for such a great guide.
 
Newbie Spellweaver
Joined
Jan 30, 2007
Messages
49
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Hmmm I'm scripting an NPC, and I'd like to know if it's possible to have the NPC check the map the player is currently on, then use an IF statement depending on the map.. I've tried a few like...
cm.getPlayerMap() == 0
cm.getMap() == 0

but they have failed = /
 
Newbie Spellweaver
Joined
Apr 24, 2008
Messages
89
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

cm.getPlayer().getMapId()
 
Experienced Elementalist
Loyal Member
Joined
Dec 15, 2007
Messages
241
Reaction score
1
Re: [Guide] Learning NPC scripts (beginner's guide)

The hell is this crap?

You have just won a free "The hell is this crap?" question award. Please redeem it with the quote above by clicking the red triangle with an exclamation mark in the middle. Next is you type, "Spam" in the text box and you will receive your award in less than 24 hours! This system is very convenient. Please do not abuse it. Thank you for your co-operation.

LOL.

Very nice guide. 10/10

:D
 
Newbie Spellweaver
Joined
Jan 30, 2007
Messages
49
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

cm.getPlayer().getMapId()


Thanks a lot, that helped me.

Get, it's a nice guide, this will certainly help people get started.

= / It seems that "status" type of NPC and "selection" aren't meant to go together..

-- I can't double post so I'll just edit in my question.

Could anyone link me to a thread telling me where I can check what NPC functions I can use? Like some place that has all of them? Whether it be somewhere in a file somewhere in the source code, or a thread with the functions. That would be wonderful, thanks!

Or do I just have to experiment until I think I know all of them? I'm sure there should be some place inside the code that defines them and what they do, so I'll try looking as well, if anyone finds it first, please tell me. If I find it, I'll edit.
 
Last edited:
Newbie Spellweaver
Joined
Apr 26, 2008
Messages
30
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Your guide is very helpful and after skimming through it for just five minutes, I've learned so much about NPCs and how they work. I've made a script but I don't have any way to test it just yet. Is there any way you can look at it and tell me how I've done? Thanks, ~iRawk

Code:
var status = 0;  

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

function action(mode, type, selection) {  
       
    if (mode == -1) {  
        cm.dispose();  
    }  
    else {   
        if (status >= 5 && mode == 0) {   
            cm.sendOk("Goodbye. If you need anything else, just talk to a GM!");   
            cm.dispose();   
            return;   
        }   
          
        if (mode == 1) {  
            status++;  
        }  
        else {  
            status--;  
        }  

            cm.sendNext("Hello #h #, I'm OurStory's Informational NPC");
        }
        else if (status == 1) { 
            cm.sendNextPrev("I am here to give you some basic info on OurStory!");
        }
        else if (status == 2) { 
	cm.sendNextPrev("Our current staff: #bNameHere#n is the owner.\r\n #bNameHere#n and #n'NameHere#n are co-Admins.\r\n #bNameHere#n is a SuperGM");
        else if (status == 3) { 
	cm.sendNextPrev("You can talk to #bCody#n in the FM to get a Job Advance, and #bGlimmerman#n maxes your skills.");
        else if (status == 4) { 
	cm.sendNextPrev("#bSera#n is our AP Reset NPC. #bAmos#b will take you to Boss Maps, and the #bMysterious Statue#b is our Town Warper NPC. These NPCs are all found in the #bFree Market#");
	else if (status == 5) {
	cm.sendOk("If you need anything else, just use one of these #bSuperMegaphones#n to ask!")
	cm.gainItem(5072000, 10)
	    cm. dispose();

	}
   }
 
Junior Spellweaver
Joined
Jul 21, 2008
Messages
124
Reaction score
47
Re: [Guide] Learning NPC scripts (beginner's guide)

@marshank

You forgot a few things.

} before the else if

you forgot one ; on the last sendOk

you forgot to have a status 0

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("Goodbye");    
            cm.dispose();    
            return;    
        }    
           
        if (mode == 1) {   
            status++;   
        }       
        else {   
            status--;   
        }   
           
        if (status == 0) { 
            cm.sendNext("Hello #h #, I'm OurStory's Informational NPC");
        }
        else if (status == 1) { 
            cm.sendNextPrev("I am here to give you some basic info on OurStory!");
        }
        else if (status == 2) { 
	        cm.sendNextPrev("Our current staff: #bNameHere#n is the owner.\r\n #bNameHere#n and #n'NameHere#n are co-Admins.\r\n #bNameHere#n is a SuperGM");
        }
        else if (status == 3) { 
	        cm.sendNextPrev("You can talk to #bCody#n in the FM to get a Job Advance, and #bGlimmerman#n maxes your skills.");
        }   
        else if (status == 4) { 
            cm.sendNextPrev("#bSera#n is our AP Reset NPC. #bAmos#b will take you to Boss Maps, and the #bMysterious Statue#b is our Town Warper NPC. These NPCs are all found in the #bFree Market#");
        }
        else if (status == 5) {
	        cm.sendOk("If you need anything else, just use one of these #bSuperMegaphones#n to ask!");
	        cm.gainItem(5072000, 10)
	        cm.dispose();
        }
    }
}
 
Newbie Spellweaver
Joined
Apr 26, 2008
Messages
30
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Awesome! Thanks alot, and once again, this guide is amazing.
 
Newbie Spellweaver
Joined
Apr 26, 2008
Messages
30
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Sorry for the double post but, is there any way to make an NPC check how many rebirths a player has?
 
Newbie Spellweaver
Joined
Dec 8, 2008
Messages
41
Reaction score
2
Re: [Guide] Learning NPC scripts (beginner's guide)

Sorry for the double post but, is there any way to make an NPC check how many rebirths a player has?

cm.getPlayer().getReborn() or cm.getPlayer().getRebirth() .
Make sure you have it implemented o_O .

- XotiCraze .
 
Initiate Mage
Joined
Oct 15, 2008
Messages
0
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Is there one for sending a party??
 
Newbie Spellweaver
Joined
Jan 30, 2007
Messages
49
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Please give more detail... "sending a party?" that's quite vague, send what do what, I'm guessing do something with an entire party, but uhh...?

I have a question as well,
How do I get an NPC to have a little box where the user can type oh say an answer to a question?

EX
NPC out: "What is the name of this server?"
User IN: "servernameMS"
store user IN into variable.

Edit:
K I got "cm.sendGetNumber("What's a number you'd like me to store, 1-100 please.",50,1,100)

Buttt how do I put that into a variable?
 
Last edited:
Junior Spellweaver
Joined
Jul 21, 2008
Messages
124
Reaction score
47
Re: [Guide] Learning NPC scripts (beginner's guide)

Please give more detail... "sending a party?" that's quite vague, send what do what, I'm guessing do something with an entire party, but uhh...?

I have a question as well,
How do I get an NPC to have a little box where the user can type oh say an answer to a question?

EX
NPC out: "What is the name of this server?"
User IN: "servernameMS"
store user IN into variable.

Edit:
K I got "cm.sendGetNumber("What's a number you'd like me to store, 1-100 please.",50,1,100)

Buttt how do I put that into a variable?

I think you mean the little white box where you can type answers inside. Here's a guide for how to use it.

http://forum.ragezone.com/f428/guide-cm-sendgettext-cm-gettext-452535/
 
Initiate Mage
Joined
Jul 24, 2008
Messages
1
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Thank you very much.
The guide is simple like knowing how to drink XD
I am still new in script "Things" so if ull have another fantastic and simple guide let me know ^^
 

Mal

Initiate Mage
Joined
Dec 10, 2008
Messages
3
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

I was wondering if you could help me understand a bit more.. I was wanting to make a rebirth NPC and all
the guides I read haven't touched on checking multiple items in the players inventory or how to remove said items
like in this portion of your script

Code:
else if (status == 1) { 
            if(cm.haveItem(2000005)) { 
                cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l"); 
            }

How could I change that to check for 2 equips and 300mil mesos? Please help me correct if terribly wrong which most likely it is.

Code:
else if (status == 1) { 
            if(cm.haveItem(01382016))
              (cm.haveItem(01332052))
              (cm.getChar().getMeso()(>=300000000))

and how would I take said Items away after rebirthing player? Again please help me correct if wrong.
Code:
else if (status == 2) {
        cm.getChar().levelUp();
        cm.unequipEverything()
        cm.gainItem(01382016,-1)
        cm.gainItem(01332052,-1)
        cm.gainMeso(-300000000)
        cm.changeJob(net.sf.odinms.client.MapleJob.BEGINNER);
        cm.sendNext("Go level up you level 1 noob =D");
        cm.getChar().setLevel(2);
        cm.dispose();

Any help is appreciated :)
 
Newbie Spellweaver
Joined
Dec 8, 2008
Messages
41
Reaction score
2
Re: [Guide] Learning NPC scripts (beginner's guide)

I was wondering if you could help me understand a bit more.. I was wanting to make a rebirth NPC and all
the guides I read haven't touched on checking multiple items in the players inventory or how to remove said items
like in this portion of your script

Code:
else if (status == 1) { 
            if(cm.haveItem(2000005)) { 
                cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l"); 
            }
I dont understand what you're saying on this part sorry .

How could I change that to check for 2 equips and 300mil mesos? Please help me correct if terribly wrong which most likely it is.

Code:
else if (status == 1) { 
            if(cm.haveItem(01382016))
              (cm.haveItem(01332052))
              (cm.getChar().getMeso()(>=300000000))
PHP:
if (cm.haveItem(01382016) && cm.haveItem(01332052) && cm.getMeso() >= 300000000) {

and how would I take said Items away after rebirthing player? Again please help me correct if wrong.
Code:
else if (status == 2) {
        cm.getChar().levelUp();
        cm.unequipEverything()
        cm.gainItem(01382016,-1)
        cm.gainItem(01332052,-1)
        cm.gainMeso(-300000000)
        cm.changeJob(net.sf.odinms.client.MapleJob.BEGINNER);
        cm.sendNext("Go level up you level 1 noob =D");
        cm.getChar().setLevel(2);
        cm.dispose();

Dont understand too ><.

'&&' = and .
'||' = or .
 

Mal

Initiate Mage
Joined
Dec 10, 2008
Messages
3
Reaction score
0
Re: [Guide] Learning NPC scripts (beginner's guide)

Ok in the first part of code I was just showing her original code.

Thanks for the help with the second part

and on the third part i'm trying to rebirth the player and take away the items I just checked for.
 
Status
Not open for further replies.
Back
Top