EXTRA INFO:
Im gonna talk about the more/equals/less symbols.
If you want to check (for example) if a player has less ITEMID than AMMOUNT, you type:
[code]
if (cm.haveItem(ITEMID) < AMMOUNT) {[/CODE]
So. The < actually checks if ITEMID is less than AMMOUNT
If you want to check if a player has more ITEMID than AMMOUNT, you type:
Code:
[COLOR="purple"]if (cm.haveItem(ITEMID) > AMMOUNT) { [/COLOR]
So. The > actually checks if ITEMID is more than AMMOUNT
If you want to check if a player has ITEMID equals AMMOUNT, you type:
Code:
[COLOR="Purple"]if (cm.haveItem(ITEMID) = AMMOUNT) { [/COLOR]
So. The = actually checks if ITEMID equals AMMOUNT
Wait! There is more..
If you want to check if a player has ITEMID less OR equals to AMMOUNT, you type:
Code:
[COLOR="purple"]if (cm.haveItem(ITEMID) <= AMMOUNT) { [/COLOR]
So. The <= actually checks if ITEMID less OR equals to AMMOUNT
If you want to check if a player has ITEMID more OR equals to AMMOUNT, you type:
Code:
[COLOR="purple"]if (cm.haveItem(ITEMID) >= AMMOUNT) { [/COLOR]
So. The >= actually checks if ITEMID more OR equals to AMMOUNT
Fast walktrough:
(ID) < (AMMOUNT) = less than
(ID) > (AMMOUNT) = more than
(ID) = (AMMOUNT) = equals
(ID) <= (AMMOUNT) = less OR equals
(ID) >= (AMMOUNT) = more OR equals
EXTRA NPC SCRIPT TEMPLATES:
Npc that you cannot leave with no or end chat:
Code:
[COLOR="purple"]var status = -1;
function start()
{
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1)
status++;
if (status == 0) {
}
} [/COLOR]
Makes that the npc will check for an item and does action or else do action:
Code:
[COLOR="purple"]if (status == 0) {
if (cm.haveItem(ITEMID <= AMMOUNT)) {
cm.sendYesNo("Hello! Do you want to trade your AMMOUNT ITEMNAME for blabla..?");
} else {
cm.sendOk("Sorry, you cannot talk to me. You will need AMMOUNT ITEMNAME to talk to me...");
}
} [/COLOR]
If above code doesn't work, tell me pl0x..
TUTORIAL 2 [How to fix a NPC if you got a problem with it]
Fixing the npc..
Have your npc never started to talk?
Or do you DC after talking to it?
[code]Maybe the npc stops talking when you click a button in the conversation window?
I will tell you how to fix those problems. It's easy.
We will look into: "Have your npc never started to talk?"
-----------------------------------------------
Open up your javascript editor and open the npc script from there or make a new javascript tab and paste in the script itself. Or if you dont want to download the JS Editors in this tut, open up the npc script manually with notepad.
If you are using a JS Editor, simply click the check for errors button (if there is any. AJAX JS Editor has one.) The normal error of the npc isn't working is syntax errors. The syntax errors is when you for example have forgot any " in for example,
Code:
[COLOR="Purple"]cm.sendOk("hello);[/COLOR]
This is a normal mistake and can easily be fixed because of that.
But if you are using notepad, (not notepad++) you have to search the errors manually and that is not recommended.
Another syntax error can be following:
You have forgotten any } or { anywhere or made an extra } or { anywhere.
Add/Delete at the place it should be/is on.
And another one:
You are using this:
Code:
[COLOR="Purple"]cm.sendOk("hello!";[/COLOR]
You noticed you forgot one )? Yeah, thats a syntax error too.
Or you maybe added an extra ) or (? that will be syntax error too.
Now on to the next part!
"Do you DC after talking to the npc or clicking a button in the npc's conversation window?"
This can happen sometimes too.
It's because you have added too much actions in a status than it can handle.
Lets say you wanted it to be like this:
Code:
[COLOR="purple"]} else if (status == 1) {
cm.gainItem(1049200);
cm.sendOk("Here you go! A random item!");
cm.dispose();
}[/COLOR]
Even this single thing can be the problem.
If so, you have to do like this:
Code:
[COLOR="purple"]} else if (status == 1) {
cm.sendOk("Here you go! A random item!");
} else if (status == 2) {
cm.gainItem(1049200);
cm.dispose();
}[/COLOR]
There is one more thing that will make this error.
Let's say you typed:
Code:
[COLOR="purple"]cm.sendNext("Hello! Pick a category: \r\n \r\n #L0##bI WANNA GO HOME#l \r\n #L1##bNevermind#k#l"); [/COLOR]
This will create a window with a next button and make a selection window at the same time. That will not work.
You have to type like this all the time for a simple selection window.
Code:
[COLOR="purple"]cm.sendSimple("Hello! Pick a category: \r\n \r\n #L0##bI WANNA GO HOME#l \r\n #L1##bNevermind#k#l");[/COLOR]
Got it? Yes? Good!
Now onto the next part.
"The npc stops talking when you click the button?"
There is 2 things that can lead to this error. The first is:
LAG! Seriously. It can be because of lag or you might have to reload the map.
The second is:
You do not have any text dialog command like cm.sendOk("");...
Well. This is not a problem if you are adding some items/etc. commands in there.
TUTORIAL 3 [The NPC commands]
Code:
cm.dispose(); - Ends chat
cm.sendNext("text"); - shows a conversation window with a next button.
cm.sendPrev("text"); - shows a conversation window with a prev button.
cm.sendNextPrev("text"); - shows a conversation window with a next and a prev button.
cm.sendOk("text"); - shows a conversation window with a OK button.
cm.sendYesNo("text"); - shows a conversation window with a yes and no button.
cm.sendAcceptDecline("text"); - shows a conversation window with a accept and
decline button.
cm.sendSimple("text"); - shows a conversation window without buttons.
cm.sendGetNumber("text", defammount, minammount, maxammount) - It makes the player choose a number between minammount and maxammount.
cm.sendGetText("text") - It makes the player be able to type in a text box.
cm.setGetText("text") - It sets the text in a players NPC text box.
cm.getText() - It gets the text typed in the text box.
cm.openShop(SHOPID) - opens a shop by SHOPID
cm.openNpc(NPCID) - starts a new npc conversation with NPCID
cm.changeJob(JOBID) - changes the job of the player to JOBID
cm.getJob() - gets the job of the player
cm.startQuest(QUESTID) - starts a quest by QUESTID
cm.completeQuest(QUESTID) - completes a quest by QUESTID
cm.forfeitQuest(QUESTID) - forfeits a quest by QUESTID
cm.getMeso() - gets the meso of the player
cm.gainMeso(NUMBER) - gives mesos to the player by NUMBER
cm.gainExp(NUMBER) - gives EXP to the player by NUMBER
cm.getNpc() - gets the current npc
cm.getFileName() - probably gets a filename.
cm.getLevel() - gets the level of the player
cm.unequipEverything() - makes the player unequip everything in equipment
cm.teachSkill(SKILLID, SKILLLEVEL, MASTERLEVEL) - teaches the player a skill by SKILLID
cm.getSkill() - gets a skill of the player
cm.clearSkills() - clears the skills of the player
cm.getPlayer() - gets the player
cm.getC() - gets the client
cm.rechargeStars() - recharges the players stars
cm.getEventManager(String event) - probably gets an event manager..
cm.showEffect(String effect) - shows an effect by ID
cm.playSound(String sound) - plays a sound by ID
cm.updateBuddyCapacity(ammount) - uodates the buddy capacity to ammount
cm.getBuddyCapacity() - gets the buddy capacity of a player
cm.setHair(ID) - sets the hair of a player by ID
cm.setFace(ID) - sets the face of a player by ID
cm.setSkin(ID) - sets the skin of a player by ID
cm.warpParty(MAPID) - warps the party to mapID (good for instances)
cm.warpRandom(MAPID) - warps to a random portal by MAPID
cm.itemQuantity(itemid) - gets quanity of itemid
cm.createMapleSquad(MapleSquadType) - creates a maplesquad by MapleSquadType
cm.getSquadMember(MapleSquadType, number) - gets squadmember by number in MapleSquadType
cm.getSquadState(MapleSquadType) - gets the state of MapleSquadType
cm.setSquadState(MapleSquadType, state) - sets the state of MapleSquadType
cm.checkSquadLeader(MapleSquadType) - checks the leader of MapleSquadType
cm.removeMapleSquad(MapleSquadType) - removes the maplesquad, MapleSquadType
cm.numSquadMembers(MapleSquadType) - gets the number of squadmembers in MapleSquadType
cm.isSquadMember(MapleSquadType) - checks wether a player is a squadmember or not in MapleSquadType
cm.addSquadMember(MapleSquadType) - adds a squadmember to MapleSquadType
cm.removeSquadMember(MapleSquadType, Char) - removes squadmember from MapleSquadType
cm.removeSquadMember(MapleSquadType, Char, ban) - removes squadmember from MapleSquadType with ban
cm.canAddSquadMember(MapleSquadType) - checks if it can add another squadmember into
cm.removeSquadMember(MapleSquadType, Char) - removes squadmember from MapleSquadType
cm.warpSquadMembers(MapleSquadType, mapId) - warps squadmembers of MapleSquadType to mapId
cm.searchItem(ItemName) - searches for ItemName
cm.makeRing(partner, ringId) - makes a ring to you and your partner bt ringId
cm.resetReactors() - resets the reactors
cm.displayGuildRanks() - displays the guild ranks
cm.sendMessage(Player, Message) - sends a message to player
cm.gainFame(amount) - gives/takes fame from player by ammount
cm.maxSkills() - maxes players skills
cm.getSkillLevel(skillid) - gets skill level by skillid from player
cm.giveBuff(skillid) - gives a player the buff of skillid
cm.partyMembersInMap() - checks for the partymembers in the map.
cm.modifyNx(amount) - modifies the nx of the player
cm.getTime(type) - get the time of type. type = h/m/s
cm.addBuddyCapacity(number) - adds the buddycapacity of number
cm.clearKeys() - sets the keys to deafult
cm.scheduleWarp(delay, mapid) - warps to mapid in delay
cm.startClock(limit, endMap) - starts a clock that will go down to 0 from limit and then warps to endmap
cm.getCharByName(name) - gets char by name
cm.warpAllInMap(mapid, portal) - warps all in the map to mapid to portal
cm.createMarriage(partner) - creates marriage with partner
cm.createEngagement(partner) - creates engagement with partner
cm.divorceMarriage() - divorces from partner
cm.changeKeyBinding(key, type, action) - changes key by type by action...
cm.getEquipById(id) - gets equip by id
cm.getNpcTalkTimes() - gets how many times som1 have talked to this npc
cm.setNpcTalkTimes(amount) - sets how many times players have talked to npc by ammount
cm.makeProItem(ITEMID, NUMBER) - makes an item by ITEMID with NUMBER to each stat (xotic)
cm.isGuest() - checks wether a player is guest or not
cm.broadcastMessage(type, message) - broadcasts message by type
cm.setClan(ClanName) - makes player enter ClanName
cm.getAllOnlineNamesFromClan(ClanName) - gets all online members names from clan
cm.getAllOfflineNamesFromClan(ClanName) - gets all offline members names from clan
cm.getOfflineClanCount(ClanName) - counts how many offline in ClanName
cm.getJobById(id) - gets job by id
cm.getPartyMembers() - gets the partymembers in a party
cm.getSender() - gets the sender of ex. a message
cm.removeHiredMerchantItem(id) - removes id from hired merchant
cm.getHiredMerchantMesos() - gets hired merchants mesos
cm.setHiredMerchantMesos(Number) - sets hired merchants mesos by number
cm.getHiredMerchantItems() - gets hired merchants items
cm.sendKeymap(KEY) - sends ? to keymap
The commands in the spoiler actually makes the npc do what the commands is used for. Some of these commands do need a variable to work.
Like this one:
First, set a var at the top.
Code:
[COLOR="Purple"]var text;[/COLOR]
Second make the actions.
Code:
[COLOR="purple"]if (status == 0) {
cm.sendGetText("Tell me, what is 1+1?");
} else if (status == 1) {
text = cm.getText();
cm.sendYesNo("So, your answer is #b" + text + " #keh?");
} else if (status == 2) {
if (text = "2") {
cm.gainMesos(1000000);
cm.sendOk("yay! you did it! Here you get 1 mill mesos.");
cm.dispose();
} else {
cm.sendOk("Sry but thats the wrong answer. Try again next time!");
cm.dispose();
}
} [/COLOR]
The npc asks a character for the answer of 1+1=. The player will be able to type in the answer in a box. If its the right answer, the player will be awarded 1 mill, otherwise the player will get none and be told to try again.
Also, some of these npc commands is IF commands. Let's get an example of, cm.isGuest()
This command checks wether a player is a guest or not. For it to work, we want to do this:
Code:
[COLOR="purple"]if (cm.getPlayer().isGuest() == 1) { [/COLOR]
This checks if the character is a guest and then do actions.
There is commands that needs to get the player before being used too. Like this one:
Code:
[COLOR="purple"]cm.giveSkill(SKILLID);
cm.getPlayer().sendKeymap(KEY);[/COLOR]
This sends SKILLID to KEY
There is more, like:
Code:
[COLOR="purple"]cm.getPlayer().gainExp(AMMOUNT); [/COLOR]
This gives AMMOUNT of exp to the player.
Please ask if you need to learn more cm.getPlayer(). commands.
The next TUT is in the other Posts because cant more write wordsxD