- Joined
- Feb 8, 2008
- Messages
- 1,873
- Reaction score
- 43
Hey, Feel free to read this if you need it, but keep the flaming to a minimum ^_^ this is my first guide, And SaintsIan Taught me some of my JS and helped me correct my scripts
and for future reference, Else means if the first if statement is false, and if statements are listing if a situation is true or false, and No its not boolean
So here i go!
Credits to ryoku for making the script,
Now for the actual explaining part xD
This little segment here states the variable in the script, so whenever you see status it will represent 0 so if i wrote
var poop = 24; then whenever i used poop in the script it would represent the number 24. ill go into that further on
Next!
What i believe this means is that the status begins at -1, so the script is starting the script with a status of -1 and the action is stated with this part of the script
so that means that (mode, type, selection) is equivelent to (1,0,0) which states that mode is used here so if i wanted to used selection i assume it would be (0,0,1)
Next!
this is exiting chat, using the bottom left corner of chat, leave option or pressing esc
Next!
this is the No selection of the sendYesNo part of the script, and to make this a bit less confusing ill point out that these come before the actual YesNo part of the script due to the fact that the script goes from lowest to highest, so mode couldnt just go from 3 - (-1) right? that wouldnt make much sense
Next!
this little segment kept me confused for a whole 3 minuites! so lets start with mode, since we just finished doing the No selection part of the script, this is most likely the Yes! so if mode == 1 (yes). Remember back in the beginning of the script the function stated status to start -1? well this is where this part comes in
This means status + 1 basically, so if we have a status of -1 and we add 1 to it, then status then becomes 0.. its simple math, therefore thats where the If statement makes sense if (status == 0);, im not too positive about the status++ or status-- but most the scripts ive looked at it seems that way, now the status-- is confusing me, if you know please post below and i will credit you for the info,
Next!
right so this little part is choosing yes but if u notice
that checks level, so lets bring back to math <,>,= is a comparison Correct? right so if we do 2 > 3 thats false because that means 2 is bigger than 3, you get the picture so if Level < 200 which is minimum level for rebirth, and the else statment just tells you that you qualified.
This part is after the sendOk was sent, it Levels you up to 1, unequips everything, makes you a beginner and ends the script!
hopefully this was helpful, Please PLEASE tell me if i made a mistake somewhere or you need clarification on something, ill be sure to give you credits
and if you need it here are commands for npcs
THANKS TO woainioh for these commands! the link is [ame="http://forum.ragezone.com/showthread.php?t=397511"]here[/ame]
And if you want me to help you with a different script or need clarification on your script dont be shy!
Credits : Me for writing this tutorial and explaining the script
woainioh for all the npc stuff listed above, his thread is found [ame="http://forum.ragezone.com/showthread.php?t=397511"]here[/ame]
ryoku for the script the script link is [ame="http://forum.ragezone.com/showthread.php?t=409263"]here[/ame]
saintsian for teaching me my JS
(Your name here if you Help or correct me!)
HOPE YOU LIKED THIS Guide!DONT FLAME ME FOR POSTING SUCH A FALIURE Guide!
Thanks for reading! :drinks_no:drinks_no:drinks_no
PLEASE PRESS THE THANKS BUTTON IF THIS HELPED
and for future reference, Else means if the first if statement is false, and if statements are listing if a situation is true or false, and No its not boolean
So here i go!
Code:
/*
@ Author : Snow
@
@ NPC = NAME
@ Map = MAP
@ NPC MapId = MAPID
@ Function = Rebirth Player
@
*/
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}else if (mode == 0){
cm.sendOk("Ok, talk to me when your sure you want to #bRebirth#k.");
cm.dispose();
}else{
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("Welcome, great hero. You have been through a long and challenging road, and you have become immensely strong. If you bring me a Maple Coin,I can use my magic to increase your power even further, and surpass your limits! You will become a level 1 Beginner again, but you will keep your stats the same and all the Skill in you Hot Keys. Do you wish to be reborn? #b(Note: Please Make Sure you Have Room for all your Equipment in your Inventory. Also Make Sure you use all your SP. As it won't Be useable in your next Job. )#k" );
}else if (status == 1) {
if(cm.getChar().getLevel() < 200){
cm.sendOk("Sorry, You have to be level 200 to rebirth.");
cm.dispose();
}else{
cm.sendOk("#bGood-Job#k, you have qualified for a #eRebirth#n.");
}
}else if (status == 2) {
cm.getChar().levelUp();
cm.unequipEverything()
cm.changeJob(net.sf.odinms.client.MapleJob.BEGINNER);
cm.sendNext("Enjoy your rebirth!(Note: You will have to Change Channels For the Full Effect to Take Place.");
cm.getChar().setLevel(2);
cm.dispose();
}
}
}
Now for the actual explaining part xD
Code:
var status = 0;
var poop = 24; then whenever i used poop in the script it would represent the number 24. ill go into that further on
Next!
Code:
function start(){
status = -1;
action(1,0,0);
}
Code:
function action(mode, type, selection) {
Next!
Code:
if (mode == -1) {
cm.dispose();
Next!
Code:
}else if (mode == 0){
cm.sendOk("Ok, talk to me when you're sure you want to be #bReborn#k.");
cm.dispose();
Next!
Code:
}else{
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendYesNo("Hi i'm Mr.Pickall Blah Blah);
Code:
status++;
Next!
Code:
}else if (status == 1) {
if(cm.getChar().getLevel() < 200){
cm.sendOk("Sorry, You have to be level 200 to rebirth.");
cm.dispose();
}else{
cm.sendOk("#bGood-Job#k, you have qualified for a #eRebirth#n.");
}
Code:
if(cm.getchar().getLevel() < 200){
Code:
}else if (status == 2) {
cm.getChar().levelUp();
cm.unequipEverything()
cm.changeJob(net.sf.odinms.client.MapleJob.BEGINNER);
cm.sendNext("Enjoy your rebirth!(Note: You will have to Change Channels For the Full Effect to Take Place.");
cm.getChar().setLevel(2);
cm.dispose();
}
}
}
hopefully this was helpful, Please PLEASE tell me if i made a mistake somewhere or you need clarification on something, ill be sure to give you credits
and if you need it here are commands for npcs
Code:
[SIZE=5]cm.[Commands][/SIZE]
[B]dispose[/B]
Ends the conversation with an NPC.
[SIZE=1]How to use: cm.dispose();[/SIZE]
[B]sendNext[/B]
Shows a conversation window with a 'Next' button.
[SIZE=1]How to use: cm.sendNext("[text]");[/SIZE]
[B]sendPrev[/B]
Shows a conversation window with a 'Prev' (previous) button.
[SIZE=1]How to use: cm.sendPrev("[text]");[/SIZE]
[B]sendNextPrev[/B]
Shows a conversation window with a 'Next' and 'Prev' button (see above).
[SIZE=1]How to use: cm.sendNextPrev("[text]");[/SIZE]
[B]sendOk[/B]
Shows a conversation window with an 'Ok' button.
[SIZE=1]How to use: cm.sendOk("[text]");[/SIZE]
[B]sendYesNo[/B]
Shows a conversation window with a 'Yes' and 'No' button, 'No' ends the conversation unless otherwise stated.
[SIZE=1]How to use: cm.sendYesNo("[text]");[/SIZE]
[B]sendAcceptDecline[/B]
Shows a conversation window with an 'Accept' and 'Decline' button. 'Decline' ends the conversation unless otherwise stated.
[SIZE=1]How to use: cm.sendAcceptDecline("[text]");[/SIZE]
[B]sendSimple[/B]
Shows a conversation window with no buttons.
[SIZE=1]How to use: cm.sendAcceptSimple("[text]");[/SIZE]
[B]sendStyle[/B]
Shows a style-select window.
[SIZE=1]How to use: cm.sendStyle("[Text]", [variable]); // You'll need to delcare the variable in a Var statement.[/SIZE]
[B]warp[/B]
Warps the player to a map.
[SIZE=1]How to use: cm.warp([mapid], [portal]); // Set [portal] as 0 if you want default.[/SIZE]
[B]openShop[/B]
Opens a shop window.
[SIZE=1]How to use: cm.openShop([shopid]);[/SIZE]
[B]haveItem[/B]
Checks if the player has an item (in their inventories or equipped).
[SIZE=1]How to use: cm.haveItem([itemid]);[/SIZE]
[B]gainItem[/B]
Gives the player an item/takes an item from a player.
[SIZE=1]How to use: cm.gainItem([itemid],[ammount]); // Change [ammount] to -[ammount] to take an item.[/SIZE]
[B]changeJob[/B]
Changes the job of the player.
[SIZE=1]How to use: cm.changeJob([jobid]);[/SIZE]
[B]getJob[/B]
Finds out what job the player has.
[SIZE=1]How to use: cm.getJob();[/SIZE]
[B]startQuest[/B]
Starts a quest.
[SIZE=1]How to use: cm.startQuest([questid]);[/SIZE]
[B]completeQuest[/B]
Finishes a quest.
[SIZE=1]How to use: cm.completeQuest([questid]);[/SIZE]
[B]forfeitQuest[/B]
Forfeits a quest.
[SIZE=1]How to use: cm.forfeitQuest([questid]);[/SIZE]
[B]getMeso[/B]
Finds out how many mesos a player has.
[SIZE=1]How to use: cm.getMeso();[/SIZE]
[B]gainMeso[/B]
Gives a player mesos/takes mesos from a player.
[SIZE=1]How to use: cm.gainMeso([ammount]); // use -[ammount] to take mesos.[/SIZE]
[B]gainExp[/B]
Gives a player exp/takes exp from a player.
[SIZE=1]How to use: cm.gainExp([ammount]); // use -[ammount] to take exp.[/SIZE]
[B]getLevel[/B]
Finds out the level of the player.
[SIZE=1]How to use: cm.getLevel();[/SIZE]
[B]teachSkill[/B]
Teaches a player a skill.
[SIZE=1]How to use: cm.teachSkill([skillid],[skilllevel],[maxskilllevel]);[/SIZE]
[B]isGM[/B]
Finds out if the player is a GM or not.
[SIZE=1]How to use: cm.isGM();[/SIZE]
[B]get[Stat][/B]
Finds out the [Stat] of the player. [Stat] being: HP, MP, STR, DEX, INT, LUK.
[SIZE=1]How to use: cm.get[Stat]();[/SIZE]
--
Some of the above can be used in IF statements. Here is an example of the Thief 1st Job Advancement:
Code:
if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
if (cm.[B]getLevel[/B]() >= 10 && cm.[B]getChar[/B]().[B]getDex[/B]() >= 25) {
cm.[B]sendNext[/B]("So you decided to become a #rThief#k?");
} else {
cm.[B]sendOk[/B]("Train a bit more and I can show you the way of the #rThief#k.")
cm.[B]dispose[/B]();
}
} else if (status == 1) {
cm.send[B]NextPrev[/B]("It is an important and final choice. You will not be able to turn back.");
} else if (status == 2) {
cm.[B]sendYesNo[/B]("Do you want to become a #rThief#k?");
} else if (status == 3) {
if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
cm.[B]changeJob[/B](net.sf.odinms.client.MapleJob.THIEF);
cm.[B]sendOk[/B]("So be it! Now go, and go with pride.");
cm.[B]dispose[/B]();
}
}
}[/CODE
Breaking this section of code apart line by line will show you some examples of how some of these NPC-related commands can be used:
Quote:
[SIZE=1]if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
if (cm.[B]getLevel[/B]() >= 10 && cm.[B]getChar[/B]().[B]getDex[/B]() >= 25) {
cm.[B]sendNext[/B]("So you decided to become a #rThief#k?");
} else {
cm.[B]sendOk[/B]("Train a bit more and I can show you the way of the #rThief#k.")
cm.[B]dispose[/B]();
}
} else if (status == 1) {
cm.send[B]NextPrev[/B]("It is an important and final choice. You will not be able to turn back.");
} else if (status == 2) {
cm.[B]sendYesNo[/B]("Do you want to become a #rThief#k?");
} else if (status == 3) {
if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.MapleJob.BEGINNER)) {
cm.[B]changeJob[/B](net.sf.odinms.client.MapleJob.THIEF);
cm.[B]sendOk[/B]("So be it! Now go, and go with pride.");
cm.[B]dispose[/B]();
}
}
}[/SIZE]
__________________________________________________ ______________________
[U][SIZE=5]MapleJob.[Job][/SIZE][/U]
These can be used with the MapleJob. statements:
[SIZE=1][B]BEGINNER[/B]
[B]WARRIOR[/B]
FIGHTER
CRUSADER
HERO
PAGE
WHITEKNIGHT
PALADIN
SPEARMAN
DRAGONKNIGHT
DARKKNIGHT
[B]MAGICIAN[/B]
FP_WIZARD
FP_MAGE
FP_ARCHMAGE
IL_WIZARD
IL_MAGE
IL_ARCHMAGE
CLERIC
PRIEST
BISHOP
[B]BOWMAN[/B]
HUNTER
RANGER
BOWMASTER
CROSSBOWMAN
SNIPER
CROSSBOWMASTER
[B]THIEF[/B]
ASSASSIN
HERMIT
NIGHTLORD
BANDIT
CHIEFBANDIT
SHADOWER
[B]GM[/B]
SUPERGM[/SIZE]
Example:
Quote:
if (cm.[B]getJob[/B]().equals(net.sf.odinms.client.[B]MapleJob.SUPERGM[/B])) {
cm.[B]sendNext[/B]("Hi, GM!");
}
These can be used to easily code a Job Advancing NPC.
__________________________________________________ ______________________
[U][SIZE=5]NPC Text Commands[/SIZE][/U]
[B]#b[/B] = Blue text.
[B]#c[itemid]#[/B] Shows how many [itemid] the player has in their inventory.
[B]#d[/B] = Purple text.
[B]#e [/B]= Bold text.
[B]#f[imagelocation]#[/B] - Shows an image inside the .wz files.
[B]#g[/B] = Green text.
[B]#h #[/B] - Shows the name of the player.
[B]#i[itemid]#[/B] - Shows a picture of the item.
[B]#k[/B] = Black text.
[B]#l[/B] - Selection close.
[B]#m[mapid]#[/B] - Shows the name of the map.
[B]#n[/B] = Normal text (removes bold).
[B]#o[mobid]#[/B] - Shows the name of the mob.
[B]#p[npcid]#[/B] - Shows the name of the NPC.
[B]#q[skillid]#[/B] - Shows the name of the skill.
[B]#r[/B] = Red text.
[B]#s[skillid]#[/B] - Shows the image of the skill.
[B]#t[itemid]#[/B] - Shows the name of the item.
[B]#v[itemid]#[/B] - Shows a picture of the item.
[B]#x[/B] - Returns "0%" (need more information on this).
[B]#z[itemid]#[/B] - Shows the name of the item.
[B]#B[%]#[/B] - Shows a 'progress' bar.
[B]#F[imagelocation]#[/B] - Shows an image inside the .wz files.
[B]#L[number]#[/B] Selection open.
[B]\r\n[/B] - Moves down a line.
And if you want me to help you with a different script or need clarification on your script dont be shy!
Credits : Me for writing this tutorial and explaining the script
woainioh for all the npc stuff listed above, his thread is found [ame="http://forum.ragezone.com/showthread.php?t=397511"]here[/ame]
ryoku for the script the script link is [ame="http://forum.ragezone.com/showthread.php?t=409263"]here[/ame]
saintsian for teaching me my JS
(Your name here if you Help or correct me!)
HOPE YOU LIKED THIS Guide!DONT FLAME ME FOR POSTING SUCH A FALIURE Guide!
Thanks for reading! :drinks_no:drinks_no:drinks_no
PLEASE PRESS THE THANKS BUTTON IF THIS HELPED
Last edited: