This Guide may seem very long but it's all spacing.
Take your time!
This guide will give you a basic walk through of scripting your NPCs. The guide will be broken into Levels each one bringing you to a more advance part of scripting an NPC.
I'm creating this script as I create the thread.
Level 1
Basic Scripting
I'm not going to launch into a full understand of the beginning of a script because this is basics. I don't want you getting confused on what it means in the beginning.
Most people start their scripts with a comment or 2 on top. A very easy comment I like to you is something like this:
PHP Code:
// get31720 of Ragezone
// Example of an NPC script
the // creates a comment LINE. Only for 1 line though. If you hit enter and start on a new line and you want to put a comment put //
OR you can use it like this:
PHP Code:
/* get31720 of Ragezone
Example of an NPC script
*\
Now to start your script. I personally like to start my scripts like this:
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
Now if you want a full explanation of this part I suggest you go to the [Guide] How to Analyze NPC scripts but if you're just here to figure out how to script something here we go.
See where it says Goodbye? That text there is what shows when someone hits Exit Chat or No in a conversation. If you don't want it to say anything just remove the cm.sendOk line and leave the cm.dispose.
Did I loose you? Click the Show button:
Spoiler:
So you lost track of where I was trying to head with all this? Knowing maplestory you know cm.sendOk must be some kind of conversation. cm.dispose(); ends a conversation. More questions? Post them.
Did I confuse you with the "just leave the cm.dispose();" thing? What I mean is currently in what I showed you if you hit Exit Chat it would say Goodbye. But you can remove the line that says sendOk("Goodbye"); and when you click Exit Chat it'll just dispose the conversation (end it)
Okay now after the status we'll code the NPC to say something to us then end. This is very simple, but it's okay to get confused. Let's add this to the script.
Colorful enough for you? Now depending on their color I've shown you how the { and } and effecting the blocks of info. If you don't get this post on the thread. If you notice there are 2 { that are not colored and 2 near the bottom that are not colored. This shows the (mode, type, selection) and mode == -1 continue through the script. When ever you use this on the top of your script just remember to stick 2 } at the bottom
You've passed Level 1
Level 2
Continuing the conversation with Next
Let's bring back the script we did in Level 1.
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
First let's change the cm.sendOk to cm.sendNext and add another cm.sendNext.
Code:
if (status == 0) {
cm.sendNext("Hello, I'm Angel's (get31720) NPC!");
cm.sendNext("I am helping people learn scripting!");
cm.dispose();
}
}
}
The red area is pointing out a very common mistake. By having both in the same status what the script is trying to do is bring up 2 conversation windows at the same time. This will ruin your script so we have to add another status.
PHP Code:
if (status == 0) {
cm.sendNext("Hello, I'm Angel's (get31720) NPC!");
}
else if (status == 1) {
cm.sendNext("I am helping people learn scripting!");
cm.dispose();
}
}
}
And TaDa you've changed your NPC to have cm.sendNext!
Now if you click the NPC it'll say: Hello, I'm Angel's (get31720) NPC!
Then if you click Next it'll say: I am helping people learn scripting
If you click Exit Chat it'll say: Goodbye
To see the finished script click Show
Spoiler:
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
if (status == 0) {
cm.sendNext("Hello, I'm Angel's (get31720) NPC!");
}
else if (status == 1) {
cm.sendNext("I am helping people learn scripting!");
cm.dispose();
}
}
}
Do you need me to show you how the { and } work when you edited this? Click Show if you need an explanation.
Spoiler:
Code:
if (status == 0) {
cm.sendNext("Hello, I'm Angel's (get31720) NPC!");
}
else if (status == 1) {
cm.sendNext("I am helping people learn scripting!");
cm.dispose();
}
}
}
The { and } are beginnings and endings of blocks of info. I'm showing you the blocks they begin/end with colors. The last 2 uncolored ones the bottom are affected from the top of the script. See the 2nd spoiler if you want the colored { and } of the Level 1 script to help you understand.
You've passed Level 2
Level 3
Learning How to use if and else
Let's say you wanted to check if someone had a power elixir and if they did it would say "Good for you" and if they didn't it would say "Here have some" and give them 10.
Let's get the level 2 script but edit the text inside to fit our situation.
We'll be concentrating on the same area again. The top part is important to the script but this is what we're editing.
PHP Code:
if (status == 0) {
cm.sendNext("If you need power elixirs I'll give you 10. If you already have some you don't need them.");
}
else if (status == 1) {
cm.sendNext("Good for you. You already have a power elixir");
cm.dispose();
}
}
}
So far all I did was change the text the NPC is going to say. Now let's add the if(cm.haveItem(2000005)) which is checking to see if they have the power elixir. (power elixir's ID is 2000005).
PHP Code:
if (status == 0) {
cm.sendNext("If you need power elixirs I'll give you 10. If you already have some you don't need them");
}
else if (status == 1) {
if(cm.haveItem(2000005)) {
cm.sendNext("Good for you. You already have a power elixir.");
cm.dispose();
}
}
}
But wait there's more! Now we need to use } else { because if the player does NOT have a power elixir we need to code what happens when the if(cm.haveItem(2000005); is false (not true)
PHP Code:
if (status == 0) {
cm.sendNext("If you need power elixirs I'll give you 10. If you already have some you don't need them");
}
else if (status == 1) {
if(cm.haveItem(2000005)) {
cm.sendNext("Good for you. You already have a power elixir.");
cm.dispose();
}
else {
cm.sendNext("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
}
}
}
}
Tada You've finished! Now the NPC will check for the power elixir. If the player has one it will say good for you and end the conversation. But if they don't have a power elixir the NPC will give the player 10.
if you want it to check for more than, less than, or equal to (>, <, and =) you can do a combination. Such as
PHP Code:
if(cm.getMeso() >= 2000)
ONLY USE > , <, = for cm.getMeso NOT for cm.haveItem
Which basically translates into if the character has more than or equal to 5 power elixirs.
The { in status ==1 doesn't end in the beginning of the script so we had to put a } at the end of the script.
Remeber if at any point you get confused post what level you got confused on and what you were having trouble understanding!
You've passed Level 3
Level 4
Learning selections
First let's learn about writing a selections and what it means. selections are the different choices you can see when you open your NPC script.
When you want an NPC to say text with a selection you need this
Code:
\r\n#L0#Can I have some anyway?#l
\r\n jumps down 1 line
#L0# begins a selection This also means that this selection is 0'; #L1# is selection 1 and so on
Can I have some anyway is the selection text
#l (this is an L not an i) ends the selection.
Now let's take the same script we just made but change the text, and lets have 2 selections.
PHP Code:
if (status == 0) {
cm.sendNext("Hello!");
}
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");
}
}
else if (status == 2) {
if (selection == 0) {
} else if (selection == 1) {
}
else {
cm.sendNext("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
}
}
}
}
Under the selections we code what we want the NPC to do. What I changed was: used cm.sendSimple for the text with selections.
added 2 selections.
Added another status because sendSimple increases the status
Moved the }else{ area higher because it has to be under the if(cm.haveItem
Now under selection 0 we're going to code for the NPC to say "Okay here you go" and give them 10 power elixirs. Under selection 1 we're going to make the NPC say See you later and dispose. And just for fun I'm going to change the cm.sendNext to cm.sendOk.
PHP Code:
if (status == 0) {
cm.sendNext("Hello!");
}
else if (status == 1) {
if(cm.haveItem(2000005)) {
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some more please?#l\r\n#L1#Nah, I don't want any.#l");
}
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005);
cm.dispose();
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
}
}
}
and TaDa we're done!
If you want to see the whole finished script click Show:
Spoiler:
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
if (status == 0) {
cm.sendNext("Hello there!");
}
else if (status == 1) {
if(cm.haveItem(2000005)) {
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some more please?#l\r\n#L1#Nah, I don't want any.#l");
}
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005);
cm.dispose();
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
}
}
}
You've passed Level 4
Level 5
Revising and Checking your script
Are all your { } correct?
Did you put ; everywhere it needed?
Did you make sure all your text in the conversation has " in the beginning and end?
Did you type any misspellings?
Test your new skills in the root section where people are looking for help with their scripts. If you can read them and correct them congratulations!
When you pass Level 5 is your own opinion
Terms to know
Click Show
NPC Text Commands
Spoiler:
#b = Blue text.
#c[itemid]# Shows how many [itemid] the player has in their inventory.
#d = Purple text.
#e = Bold text.
#f[imagelocation]# - Shows an image inside the .wz files.
#g = Green text.
#h # - Shows the name of the player.
#i[itemid]# - Shows a picture of the item.
#k = Black text.
#l - Selection close.
#m[mapid]# - Shows the name of the map.
#n = Normal text (removes bold).
#o[mobid]# - Shows the name of the mob.
#p[npcid]# - Shows the name of the NPC.
#q[skillid]# - Shows the name of the skill.
#r = Red text.
#s[skillid]# - Shows the image of the skill.
#t[itemid]# - Shows the name of the item.
#v[itemid]# - Shows a picture of the item.
#x - Returns "0%" (need more information on this).
#z[itemid]# - Shows the name of the item.
#B[%]# - Shows a 'progress' bar.
#F[imagelocation]# - Shows an image inside the .wz files.
#L[number]# Selection open.
\r\n - Moves down a line.
cm.[Commands]
Spoiler:
dispose
Ends the conversation with an NPC.
How to use: cm.dispose();
sendNext
Shows a conversation window with a 'Next' button.
How to use: cm.sendNext("[text]");
sendPrev
Shows a conversation window with a 'Prev' (previous) button.
How to use: cm.sendPrev("[text]");
sendNextPrev
Shows a conversation window with a 'Next' and 'Prev' button (see above).
How to use: cm.sendNextPrev("[text]");
sendOk
Shows a conversation window with an 'Ok' button.
How to use: cm.sendOk("[text]");
sendYesNo
Shows a conversation window with a 'Yes' and 'No' button, 'No' ends the conversation unless otherwise stated.
How to use: cm.sendYesNo("[text]");
sendAcceptDecline
Shows a conversation window with an 'Accept' and 'Decline' button. 'Decline' ends the conversation unless otherwise stated.
How to use: cm.sendAcceptDecline("[text]");
sendSimple
Shows a conversation window with no buttons.
How to use: cm.sendAcceptSimple("[text]");
sendStyle
Shows a style-select window.
How to use: cm.sendStyle("[Text]", [variable]); // You'll need to delcare the variable in a Var statement.
warp
Warps the player to a map.
How to use: cm.warp([mapid], [portal]); // Set [portal] as 0 if you want default.
openShop
Opens a shop window.
How to use: cm.openShop([shopid]);
haveItem
Checks if the player has an item (in their inventories or equipped).
How to use: cm.haveItem([itemid]);
gainItem
Gives the player an item/takes an item from a player.
How to use: cm.gainItem([itemid],[ammount]); // Change [ammount] to -[ammount] to take an item.
changeJob
Changes the job of the player.
How to use: cm.changeJob([jobid]);
getJob
Finds out what job the player has.
How to use: cm.getJob();
startQuest
Starts a quest.
How to use: cm.startQuest([questid]);
completeQuest
Finishes a quest.
How to use: cm.completeQuest([questid]);
forfeitQuest
Forfeits a quest.
How to use: cm.forfeitQuest([questid]);
getMeso
Finds out how many mesos a player has.
How to use: cm.getMeso();
gainMeso
Gives a player mesos/takes mesos from a player.
How to use: cm.gainMeso([ammount]); // use -[ammount] to take mesos.
gainExp
Gives a player exp/takes exp from a player.
How to use: cm.gainExp([ammount]); // use -[ammount] to take exp.
getLevel
Finds out the level of the player.
How to use: cm.getLevel();
teachSkill
Teaches a player a skill.
How to use: cm.teachSkill([skillid],[skilllevel],[maxskilllevel]);
isGM
Finds out if the player is a GM or not.
How to use: cm.isGM();
get[Stat]
Finds out the [Stat] of the player. [Stat] being: HP, MP, STR, DEX, INT, LUK.
How to use: cm.get[Stat]();
gainNX
Gives/Takes the player nx
How to use: cm.gainNX([amount]);
Make it negative to make it take away.
NPC commands to check for mesos,items, donator, gm, gender
Spoiler:
Code:
if(cm.getChar().isGM()
checks for GM
Code:
if(cm.getChar().isDonator() == true) { //checks for donator
Does spacing matter?
Nope, you can make a script without the spacing you see here but it's messy and harder to edit.
If I want to talk to you how should I?
PM me, leave me a visitor message, or post here. One person was worried about posting here and it being "bumping an old thread" It's not really that old unless it's been 2 months since the last post.
I've been trying to talk to you why aren't you replying?!?!
I'm not an expert at scripting but I won't take being called a beginner at it either. If I don't respond I: am too busy to help, didn't see your message, don't know the answer, don't know the answer and too busy to go search an answer for you. There are plenty of other good coders talk to them too :):
How can I get answers to questions like you do if you're not an expert
Here's the secret. SEARCHING. You can find almost ANYTHING searching. I don't have everything about private servers in my head :huh:
This command isn't working or doesing exist. (Most people ask about the NPC's mob spawing command)
Okay, repacks could have different NPCConversationManagers so if the command that you found here isn't working open your NPCConversationManager and search and try to find the command you want. For example, you could search spawn. Things that are after the public void are the commands you put after the cm.
How do I use the script once I've made it?
Save it as a .js which stands for java script. Place the script in the scripts > npc folder where all the other NPC scripts are.
They way you start you scripts are different from everyone else. It's longer, why is that?
The way I start my scripts when I first started scripting was like this. I actually would recommend you trying a different way. There are certain ways to start your scripts so you can use No to do something different in the YesNo box. I'd recommend trying different ways that are shorter or better.
If you have questions about your scripts post them
I will update this guide if needed.
FAQ
Can you explain spacing and knowing how many } go on the bottom? I feel confused :huh:
I'll gladly show you how. First I'll throw together a very simple script. Click show to see the script. I feel that long guides make people uncomfortable :):
Spoiler:
PHP 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 >= 2 && mode == 0) {
cm.dispose();
return;
}
if (mode == 1) {
status++;
}
else {
status--;
}
if (status == 0) {
cm.sendNext("Hi");
}
else if (status == 1) {
cm.sendOk("Bye");
cm.dispose();
}
}
}
If you've looked at enough scripts you'll see that sometimes the spacing varies. YOU can choose. Some people prefer using the tab as a spacing. I prefer using 4 spaces, 1,2,3,4. There's no need to memorize how the spacing goes. Soon you'll be able to do spacing like a natural. More importantly is using your spacing to understand when you're missing {}.
When you space correctly and you end your script the } should be flowing downward. Let's take my 4 spaces for example.
else if (status == 1) {
cm.sendOk("Bye");
cm.dispose();
} //ends line else if (status == 1) {
} //ends line else {
} //ends line function action(mode, type, selection) {
everything that began has to end. With my particular beginning of the script you should have 2 } at the bottom to end the else on top and the function action(mode, type, selection)
If the script had something like an if and else you'd have more }. let's change the bottom of the script.
That's it for my explanation. If you're confused on why the beginning of my script requires 2 } click the Show button. More questions? Post them. You may not know it but I check back to this thread a lot.
Spoiler:
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) { //begins here
if (mode == -1) { // notice the { above didn't end yet
cm.dispose();
} // this ends mode == -1
else { // this also begins here
if (status >= 2 && mode == 0) { // notice the { above wasn't closed off either
cm.dispose();
return;
} // ends status >= 2
if (mode == 1) { // begins
status++;
} // ends mode == 1
else { // begins
status--;
} // ends the else { above
if (status == 0) {
MobID - Monster ID HP - Custom HP, put in the amount you want. MP - Custom MP, put in the amount you want. Level - Level of the Mob EXP - Custom EXP, put in the amount you want. boss - If it is a boss put a 1. If not a 0. undead - If it's undead put a 1. If not a 0. amount - The number it spawns x - X coordinate y - Y coordinate
So it should look like this (code was taken from ThePack's mob spawner I did NOT create this and I was too lazy to make up one ;D):
Um, Angel.. Hope you dont mind me calling you that :X
Just to point out that the script in Level 4 wouldn't really work, i'm not really sure too, didnt try -.-
Correct me if i'm wrong please.. Sorry for being extra x.x
amongst the best one made so far :)
Great work xD
Now if you do a bit of defining here and there, annotating, screenshot, it will be more than perfect.
Um, Angel.. Hope you dont mind me calling you that :X
Just to point out that the script in Level 4 wouldn't really work, i'm not really sure too, didnt try -.-
Correct me if i'm wrong please.. Sorry for being extra x.x
Opps you're right I added 1 too many } in the script and I forgot a cm.dispose(); lemme just edit that :):
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
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.
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.
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();
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();
}
}
}
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 ^^
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();
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 .
Quote:
Originally Posted by Mal
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 Code:
if (cm.haveItem(01382016) && cm.haveItem(01332052) && cm.getMeso() >= 300000000) {
Quote:
Originally Posted by Mal
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();
is it possible for you to add a more advance one? Cause I'm having troubles making an NPC checking two things. It's not working out for me =/
PHP Code:
// Credits to Moogra 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 1 billion mesos for a #b#v4000313##k? Or do you want to trade in my #b#v4000313##k for 1 billion mesos?\r\n#L1# I would like to trade my #b#v4000313##k for 1 billion mesos!#l\r\n\#L2# I would like to exchange 1 billion mesos for a #b#v4000313##k!#l"); } else if (status == 1) { if (selection == 1) { if(cm.haveItem(4000313)) { cm.gainMeso(1000000000); cm.gainItem(4000313,-1); cm.sendOk("Thank you for your mesos!"); } else { cm.sendOk("Sorry, you don't have a #b#v4000313##k!"); } cm.dispose(); } else if (status == 2) { } else if (selection == 2) { if(cm.getMeso() >= 1000000000) { cm.gainMeso(-1000000000); cm.gainItem(4000313,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"); } } } }
I want to make it so when it checks for a Golden Maple Leaf it also checks if the player has 2bil so no one loses their Golden Maple Leaves for nothing.
I made it so it checks if they have more than or equal to 1.2bil. If they have 1.2bil or more it won't exchange the maple leaf for 1bil.
Untested. Try it. Tell me if it works. If it doesn't I'll look over it again incase I missed something
PHP Code:
// Credits to Moogra
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}
else {
if (status >= 3 && mode == 0) {
cm.sendOk("All right. Come back later");
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 1 billion mesos for a #b#v4000313##k? Or do you want to trade in my #b#v4000313##k for 1 billion mesos?\r\n#L1# I would like to trade my #b#v4000313##k for 1 billion mesos!#l\r\n\#L2# I would like to exchange 1 billion mesos for a #b#v4000313##k!#l");
}
else if (status == 1) {
if (selection == 1) {
if(cm.getMeso() >= 1200000000) {
cm.sendOk("You seem to have 1.2bil. You do not have enough space for another bil.");
cm.dispose();
}
else if(cm.haveItem(4000313)) {
cm.gainMeso(1000000000);
cm.gainItem(4000313,-1);
cm.sendOk("Thank you for your mesos!");
cm.dispose();
}
else {
cm.sendOk("Sorry, you don't have a #b#v4000313##k!");
cm.dispose();
}
}
else if (selection == 2) {
if(cm.getMeso() >= 1000000000) {
cm.gainMeso(-1000000000);
cm.gainItem(4000313,1);
cm.sendOk("Thank you for your item!");
cm.dispose();
}
else {
cm.sendOk("Sorry, you don't have enough mesos!");
cm.dispose();
}
}
}
}
}
Wow! Thanks a lot. Can you teach me these things ><
It's confusing me. And Merry Belated Christmas! and it worked.
The best way is to practice making your own scripts first. If the scripts don't work PM them to me or post them here. I'll fix it and tell you what you forgot.
Hey get1720.
You must have helped me a lot already, but...
Is there a way to make it so that if you talk to the NPC, you character gets to a higher level in the MySQL database. Like...
"Hello, want to become a GM?"
"Okay, you are now a GM, please relog for everything to take effect such as the ! commands."
Your finished script at bottom of level 4 doesn't work. I copied it exactly, when I click it, It comes up with a window that says "Hello!" when you hit next, the chat window disappears and glitches so I have to change channel to talk to any npc again.
if (status == 0) {
cm.sendNext("Hello!");
}
else if (status == 1) {
if (cm.haveItem(2000005, 1)) {
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l");
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005, 1);
cm.dispose();
} else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
}
}
}
if (status == 0) {
cm.sendNext("Hello!");
} else if (status == 1) {
if (cm.haveItem(2000005, 1))
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l");
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
} else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005);
cm.dispose();
} else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
}
}
}
if (status == 0) {
cm.sendNext("Hello!");
}
else if (status == 1) {
if (cm.haveItem(2000005, 1)) {
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l");
}
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005);
cm.dispose();
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
}
}
}
Hey guys, I'm new here but keen to learn how to code for Maple Story. Could someone have a look other this script I made and point out any problems with it?
The idea of it is to see if the user has ilbis, and then go on from there. (Its based around the end script of the tutorial :) )
Thanks,
Cloud.
Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
if (status == 0) {
cm.sendNext("Why, hello there my fellow ninja. It seems you may be in need of some throwing stars...");
}
else if (status == 1) {
if cm.haveItem(ILBI ID HERE);
cm.sendSimple("Ah, it seems you already have some. Shame. Do you want some more?")
}
else {
cm.sendOk("Ummm, seems you could use some. Here, take these.");
cm.gainItem(ILBI ID HERE, 5);
cm.dispose();
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("These should help you with your hunting");
cm.gainItem(ILBI ID HERE, 5);
cm.dispose();
} else if (selection == 1) {
cm.sendOk("Goodbye");
cm.dispose();
}
}
}
}
the cm.haveitem part didn't have ( , ) , or { which you needed
Forgot a semi colon (;) at the end of the sendSimple
Forgot to use \r\n#L0#text#l to show the selection. (I just changed it to YesNo)
\r\n = skip one line
#L0# = selection 0 (also #L1# would be selection 1, #L2# would be selection 2, etc.
#l = ends selection
PHP Code:
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
if (status == 0) {
cm.sendNext("Why, hello there my fellow ninja. It seems you may be in need of some throwing stars...");
}
else if (status == 1) {
if (cm.haveItem(ILBI ID HERE,1)) {
cm.sendYesNo("Ah, it seems you already have some. Shame. Do you want some more?");
}
else {
cm.sendOk("Ummm, seems you could use some. Here, take these.");
cm.gainItem(ILBI ID HERE, 5);
cm.dispose();
}
}
else if (status == 2) {
cm.sendOk("These should help you with your hunting");
cm.gainItem(ILBI ID HERE, 5);
cm.dispose();
}
}
}
Hey everyone great guide but i'm having a bit of a problem...
I have this script and when I use the NPC it give me an error is the START command prompt thingy
Here's the script
Code:
/** Nanami of RageZone **/
/** Pleased if I helped ((: **/
importPackage(net.sf.odinms.client);
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("Friggin nib.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("You will need the following items to rebirth \r\n#ePyogo Mushroom\r\nBlood Dagger#n\r\nand #e300mil#n\r\nDo you wish to be reborn?");
}
else if (status == 1) {
if ((cm.haveItem(1382016, 1)) && (cm.haveItem(1332052, 1)) && (cm.haveMeso(300000000))) {
cm.sendYesNo("You sure you want to reborn?");
}
else if (!cm.haveItem(1382016, 1)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
}
else if (!cm.haveItem(1332052, 1)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
}
else if (!cm.haveMeso(300000000)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
Dec 23, 2008 10:05:34 AM net.sf.odinms.scripting.npc.NPCScriptManager action
SEVERE: Error executing NPC script.
java.lang.reflect.UndeclaredThrowableException
at $Proxy3.action(Unknown Source)
at net.sf.odinms.scripting.npc.NPCScriptManager.action(NPCScriptManager.
java:50)
at net.sf.odinms.net.channel.handler.NPCMoreTalkHandler.handlePacket(NPC
MoreTalkHandler.java:2Cool
at net.sf.odinms.net.MapleServerHandler.messageReceived(MapleServerHandl
er.java:135)
at org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messa
geReceived(AbstractIoFilterChain.java:570)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageR
eceived(AbstractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(Abst
ractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.mess
ageReceived(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput.flus
h(SimpleProtocolDecoderOutput.java:5Cool
at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Prot
ocolCodecFilter.java:180)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageR
eceived(AbstractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(Abst
ractIoFilterChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.mess
ageReceived(AbstractIoFilterChain.java:648)
at org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorF
ilter.java:220)
at org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.
run(ExecutorFilter.java:264)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnabl
e.java:51)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.PrivilegedActionException: javax.script.ScriptException
: sun.org.mozilla.javascript.internal.EvaluatorException: Can't find method net.
sf.odinms.client.MapleCharacter.getPet(). (<Unknown>#40) in <Unknown> at line number 40
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocati
onHandler.invoke(Unknown Source)
... 19 more
Caused by: javax.script.ScriptException: sun.org.mozilla.javascript.internal.Eva
luatorException: Can't find method net.sf.odinms.client.MapleCharacter.getPet().
(<Unknown>#40) in <Unknown> at line number 40
at com.sun.script.javascript.RhinoScriptEngine.invoke(Unknown Source)
at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(Unknown So
urce)
at com.sun.script.util.InterfaceImplementor$InterfaceImplementorInvocati
onHandler$1.run(Unknown Source)
... 21 more
Any help on this would be VERY much appreciated <333
if (status == 0) {
cm.sendNext("Hello!");
}
else if (status == 1) {
if (cm.haveItem(2000005, 1)) {
cm.sendSimple("You have power elixirs.\r\n#L0#Can I have some anyway?#l\r\n#L1#I'll see you later#l");
}
else {
cm.sendOk("You don't have a power elixir? Here I'll give you 10!");
cm.gainItem(2000005, 10);
cm.dispose();
}
}
else if (status == 2) {
if (selection == 0) {
cm.sendOk("Okay here you go");
cm.gainItem(2000005);
cm.dispose();
}
else if (selection == 1) {
cm.sendOk("See you later");
cm.dispose();
}
}
}
}
the cm.haveitem part didn't have ( , ) , or { which you needed
Forgot a semi colon (;) at the end of the sendSimple
Forgot to use \r\n#L0#text#l to show the selection. (I just changed it to YesNo)
\r\n = skip one line
#L0# = selection 0 (also #L1# would be selection 1, #L2# would be selection 2, etc.
#l = ends selection
I forget the ; in C, I forget the ; in java :)
Thanks for the help. I'll be sure to post some more conplex scripts at some point.
I have a question.
I'm searching a command to warp all players in a pq.
If u talk to the npc and with a party of 4/5/6 ppl that they can get warped to the pq map.
/** Nanami of RageZone **/
/** Pleased if I helped ((: **/
importPackage(net.sf.odinms.client);
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("Friggin nib.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("You will need the following items to rebirth \r\n#ePyogo Mushroom\r\nBlood Dagger#n\r\nand #e300mil#n\r\nDo you wish to be reborn?");
}
else if (status == 1) {
if (cm.haveItem(1382016, 1) && (cm.haveItem(1332052, 1)) && (cm.haveMeso(300000000)) {
cm.sendYesNo("You sure you want to reborn?");
}
else if (!cm.haveItem(1382016, 1)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
}
else if (!cm.haveItem(1332052, 1)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
}
else if (!cm.haveMeso(300000000)) {
cm.sendOk("Friggin nib, you are missing one or more of the items. Check your inventory then talk to me again.");
cm.dispose();
You're looking for explanations to understanding the beginning of the script. Look for Clysse's guide on analyzing NPC scripts. There's a link of it in the release section
Why do I use this top?
When I first started learning java scripting I always began the beginning of my script the same way. It never failed me so I'm attached to using it :):
You're looking for explanations to understanding the beginning of the script. Look for Clysse's guide on analyzing NPC scripts. There's a link of it in the release section
Why do I use this top?
When I first started learning java scripting I always began the beginning of my script the same way. It never failed me so I'm attached to using it :):
Nah I want your explanation =) clysse's is correct to some extent but not all of it is correct.
You're looking for explanations to understanding the beginning of the script. Look for Clysse's guide on analyzing NPC scripts. There's a link of it in the release section
Why do I use this top?
When I first started learning java scripting I always began the beginning of my script the same way. It never failed me so I'm attached to using it :):
@priest - As Xoti said, you have used cm.haveItem wrong.
This would work fine.
PHP 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 >= 2 && mode == 0) {
cm.sendOk("Alright, see you next time.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hi, I'm the Items Exchanger! ");
} else if (status == 1) {
cm.sendNextPrev("Click next.")
} else if (status == 2) {
if (cm.haveItem(2000005) {
cm.sendNext("Great, you've clicked next");
}
} else if (status == 3) {
cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#l");
} else if(status == 4) {
if (selection == 0) {
if (cm.haveItem(2000005, 2000) {
cm.sendOk("There you have it!");
cm.gainItem(1002140, 1);
cm.gainItem(2000005, -2000);
cm.dispose();
}
else cm.sendOk("You do not have enough elixirs");
cm.dispose();
}
}
}
}
You only need to have an exact amount in you must have 2000 of 2000005 to obtain it. Even if you have more, your script is only going to take 2000 so this would work fine.
EDIT - Oh, I also noticed you double bracketed on the cm.haveItem commands , yours looked like this:
(cm.haveItem 2000005, 2000)) <---- You only need 1 )
@priest - As Xoti said, you have used cm.haveItem wrong.
This would work fine.
PHP 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 >= 2 && mode == 0) {
cm.sendOk("Alright, see you next time.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hi, I'm the Items Exchanger! ");
} else if (status == 1) {
cm.sendNextPrev("Click next.")
} else if (status == 2) {
if (cm.haveItem(2000005) {
cm.sendNext("Great, you've clicked next");
}
} else if (status == 3) {
cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#l");
} else if(status == 4) {
if (selection == 0) {
if (cm.haveItem(2000005, 2000) {
cm.sendOk("There you have it!");
cm.gainItem(1002140, 1);
cm.gainItem(2000005, -2000);
cm.dispose();
}
else cm.sendOk("You do not have enough elixirs");
cm.dispose();
}
}
}
}
You only need to have an exact amount in you must have 2000 of 2000005 to obtain it. Even if you have more, your script is only going to take 2000 so this would work fine.
EDIT - Oh, I also noticed you double bracketed on the cm.haveItem commands , yours looked like this:
(cm.haveItem 2000005, 2000)) <---- You only need 1 )
wow thanks!but when it comes to this line:
Code:
if (cm.haveItem(2000005, 2000) {
you need another ')' to close the code,is it?or it will just only close the '(' beside 2000005
@priest - As Xoti said, you have used cm.haveItem wrong.
This would work fine.
PHP 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 >= 2 && mode == 0) {
cm.sendOk("Alright, see you next time.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hi, I'm the Items Exchanger! ");
} else if (status == 1) {
cm.sendNextPrev("Click next.")
} else if (status == 2) {
if (cm.haveItem(2000005) {
cm.sendNext("Great, you've clicked next");
}
} else if (status == 3) {
cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#l");
} else if(status == 4) {
if (selection == 0) {
if (cm.haveItem(2000005, 2000) {
cm.sendOk("There you have it!");
cm.gainItem(1002140, 1);
cm.gainItem(2000005, -2000);
cm.dispose();
}
else cm.sendOk("You do not have enough elixirs");
cm.dispose();
}
}
}
}
You only need to have an exact amount in you must have 2000 of 2000005 to obtain it. Even if you have more, your script is only going to take 2000 so this would work fine.
EDIT - Oh, I also noticed you double bracketed on the cm.haveItem commands , yours looked like this:
(cm.haveItem 2000005, 2000)) <---- You only need 1 )
and now i have another prob.the script i have,i can even exchange the wizet invincible hat even with 1 2000005!!!!i am suppose to do i such that i need 2000 '2000005's.i wan the script to be that i i have only 1 '2000005',i cannot exchange and the npc will reply 'you do not have enough 2000005s'.i think it needs this:
Code:
if(cm.haveItem(200005 >= 2000)){
cm.gainItem(2000005, -2000);
cm.gainItem(WIZET INVINCIBLE HAT ID, 1);
cm.dispose();
}
else cm.sendOk("You do not have enough 2000005s");
cm.dispose();
Anyway, get31372.. I'm still waiting for your explanation Mr pro.:):
thanks!haha another prob now..
PHP 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 >= 2 && mode == 0) { cm.sendOk("Alright, see you next time."); cm.dispose(); return; } if (mode == 1) status++; else status--; if (status == 0) { cm.sendNext("Hi #r#h ##k, I'm the #bItems#k Exchanger! "); } else if (status == 1) { cm.sendAcceptDecline("Click accept") } else if (status == 2) { if (cm.haveItem(2000005)) { cm.sendNext("Great, you have a 2000005"); } } else if (status == 3) { cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#k(#r2000 pwr elixirs#k)#l\r\n#L1# elixirs 30000(#r1 pwr elixir#k)#l\r\n#L2#Crystal Ilbi 1 Set(#r1 pwr elixir#k)#l"); } else if(status == 4) { if (selection == 0) { cm.sendYesNo("Are you sure you want to exchange #bWizet Invincible Hat#k?"); } else if (selection == 1) { cm.sendYesNo("Are you sure you want to exchange #b30000 Power Elixirs#k?"); } else if (selection == 2) { cm.sendOk("There you have it!"); cm.gainItem(2070016, 1); cm.gainItem(2000005, -1); cm.dispose(); } } else if(status == 5) { if(cm.haveItem(2000005, 2000)){ if(cm.haveItem(1002140)){ cm.sendOk("You already have a #bWizet Invincible hat#k !! Why would you need one more?And,thanks for the #rpwr elixirs!"); cm.gainItem(2000005, -10000); cm.dispose(); } else cm.sendOk("There you have it!"); cm.gainItem(1002140, 1); cm.gainItem(2000005, -2000); cm.dispose(); } else cm.sendOk("You do not have enough pwr elixirs"); cm.dispose(); } else if(status == 6) { cm.sendOk("Here's your #b30000 Elixirs#k!"); cm.gainItem(2000004, 30000); cm.gainItem(2000005, -1); cm.dispose(); } } }
when i click 'Yes' in "Are you sure you want to exchange 30000 Elixirs?" it brings me to the WIZET INVINCIBLE HAT THING!!!pls help to solve this prob.
about ur guide
er i think you have a typo here: gainNX
Gives/Takes the player nx
How to use: gm.gainNX([amount]); <---is it gm.gainNX or cm.gainNX
Make it negative to make it take away.
about ur guide
er i think you have a typo here: gainNX
Gives/Takes the player nx
How to use: gm.gainNX([amount]); <---is it gm.gainNX or cm.gainNX
Make it negative to make it take away.
@your script
I rushed a bit, I have to leave. If it doesn't work tell me I might have missed something.
PHP Code:
var status = 0;
var choice = 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("Alright, see you next time.");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendNext("Hi #r#h ##k, I'm the #bItems#k Exchanger!");
}
else if (status == 1) {
cm.sendAcceptDecline("Click accept");
}
else if (status == 2) {
if (cm.haveItem(2000005)) {
cm.sendNext("Great, you have a 2000005");
}
else {
cm.sendOk("Get pwr elixirs before talking to me.");
cm.dispose();
}
}
else if (status == 3) {
cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#k(#r2000 pwr elixirs#k)#l\r\n#L1# elixirs 30000(#r1 pwr elixir#k)#l\r\n#L2#Crystal Ilbi 1 Set(#r1 pwr elixir#k)#l");
}
else if(status == 4) {
if (selection == 0) {
cm.sendYesNo("Are you sure you want to exchange #bWizet Invincible Hat#k?");
choice = 1;
}
else if (selection == 1) {
cm.sendYesNo("Are you sure you want to exchange #b30000 Power Elixirs#k?");
choice = 2;
}
else if (selection == 2) {
cm.sendOk("There you have it!");
cm.gainItem(2070016, 1);
cm.gainItem(2000005, -1);
cm.dispose();
}
}
else if(status == 5) {
if (choice == 1) {
if(cm.haveItem(2000005, 2000) && cm.haveItem(1002140)) {
cm.sendOk("You already have a #bWizet Invincible hat#k !! Why would you need one more?And,thanks for the #rpwr elixirs!");
cm.gainItem(2000005, -10000);
cm.dispose();
}
else if (cm.haveItem(2000005, 2000)) {
cm.sendOk("There you have it!");
cm.gainItem(1002140, 1);
cm.gainItem(2000005, -2000);
cm.dispose();
}
else {
cm.sendOk("You do not have enough pwr elixirs");
cm.dispose();
}
}
else if (choice == 2) {
cm.sendOk("Here's your #b30000 Elixirs#k!");
cm.gainItem(2000004, 30000);
cm.gainItem(2000005, -1);
cm.dispose();
}
}
}
}
Hey I made a script for when you rebirth, you talk to an NPC and they give you level 0 clothes. This is what I made so far, but it only goes to the first part of the text and not the next can you see what is wrong with it?
PHP Code:
var wui = 0;
function start() { cm.sendNext ("Hello, if you have just rebirthed and do not got level 0 equipment, press next to get them."); }
function action(mode, type, selection) { cm.dispose(); if (selection == 0) { cm.gainItem(1102041,1); cm.gainItem(1002357,1); cm.gainItem(1442018,1); cm.gainItem(1442039,1);
cm.sendOk ("Ok, let the training begin!"); } }
Also I made this of the same thing but the NPC just don't open for this.
PHP Code:
var status = 0;
function start() { status = -1; action(1, 0, 0); }
if (status == 2) { cm.sendNext("#bHello #h#, Welcome to FallenStory. If you have rebirthed and you DO NOT got a level 0 weapon or Level 0 armour, click "Next" to get a Begginers items.#b"); } else if (status == 3) { cm.sendNextPrev("#d#eHere you go.#e#d \r\n\r\n#b#eThis is what you will get..#e#b \r\n#i<1040002># #i<1060002># #i<1072005># #i<1302000>#"); cm.gainItem(1040002,1) cm.gainItem(1060002,1) cm.gainItem(1072005,1) cm.gainItem(1302000,1) cm.dispose(); } } }
First one you didn't use #L0#selection#l to make a selection
Second one change the status == 2 to a status == 0 and the status == 3 to a status == 1
You also forgot semi colons (;) at the end of the gainItem lines
if (status == 0) {
cm.sendNext("#bHello #h#, Welcome to FallenStory. If you have rebirthed and you DO NOT got a level 0 weapon or Level 0 armour, click "Next" to get a Begginers items.#b");
}
else if (status == 1) {
cm.sendNextPrev("#d#eHere you go.#e#d \r\n\r\n#b#eThis is what you will get..#e#b \r\n#i<1040002># #i<1060002># #i<1072005># #i<1302000>#");
cm.gainItem;(1040002,1)
cm.gainItem;(1060002,1)
cm.gainItem;(1072005,1)
cm.gainItem;(1302000,1)
cm.dispose();
}
}
}
function start() {
mysterious = -1;
action(1, 0, 0);
}
function action(cake, type, selection) {
if (cake == 1)
mysterious++;
else {
cm.dispose();
return;
}
if (mysterious == 0)
cm.sendNext("Hello, if you have just rebirthed and do not got level 0 equipment, press next to get them.");
else {
var items = new Array(1102041, 1002357, 1442018, 1442039);
for (var i = 0; i < items.length; i++)
cm.gainItem(items[i], 1);
cm.sendOk ("Ok, let the training begin!");
cm.dipose();
}
}
@ priest
PHP Code:
var status;
var choice;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1)
status++;
else if (mode == -1) {
cm.dispose();
return;
} else { // mode == 0 is the only possible thing in our case.
cm.sendOk("Alright, see you next time.");
cm.dispose();
}
if (status == 0) {
cm.sendNext("Hi #r#h ##k, I'm the #bItems#k Exchanger! ");
} else if (status == 1) {
cm.sendAcceptDecline("Click accept")
} else if (status == 2) {
if (cm.haveItem(2000005))
cm.sendNext("Great, you have a 2000005");
else {
cm.sendNext("MrMysterious is awesome <3.\r\n\r\nYou do not have a #v2000005#");
cm.dispose();
}
} else if (status == 3) {
cm.sendSimple("What would you like to exchange?\r\n#L0##bWizet Invincible Hat#k(#r2000 pwr elixirs#k)#l\r\n#L1# elixirs 30000(#r1 pwr elixir#k)#l\r\n#L2#Crystal Ilbi 1 Set(#r1 pwr elixir#k)#l");
} else if(status == 4) {
choice = selection;
if (selection == 0) {
cm.sendYesNo("Are you sure you want to exchange #bWizet Invincible Hat#k?");
} else if (selection == 1) {
cm.sendYesNo("Are you sure you want to exchange #b30000 Power Elixirs#k?");
} else if (selection == 2) {
cm.sendOk("There you have it!");
cm.gainItem(2070016, 1);
cm.gainItem(2000005, -1);
cm.dispose();
}
} else if (status == 5) {
switch (choice) {
case 0:
if (cm.haveItem(2000005, 2000)) {
if (cm.haveItem(1002140))
cm.sendOk("You already have a #bWizet Invincible hat#k !! Why would you need one more? And,thanks for the #rpwr elixirs!");
else {
cm.gainItem(1002140, 1);
cm.sendOk("There you have it!");
}
cm.gainItem(2000005, -10000);
} else
cm.sendOk("You do not have enough pwr elixirs");
cm.dispose();
break;
case 1:
if (cm.haveItem(2000005)) {
cm.gainItem(2000004, 30000);
cm.gainItem(2000005, -1);
cm.sendOk("Here's your #b30000 Elixirs#k!");
} else
cm.sendNext("MrMysterious is awesome <3.\r\n\r\nYou do not have a #v2000005#"); // Yeah I know, we made a check earlier but I like my name to be everything <3 LOL
cm.dispose();
}
}
}