Re: [Release]1st and 2nd Job Npcs (Have to collect dark marbles for 2nd job adv.)
First of all, thanks for this great script =). I'm still using this script w/ a few fixes I had to do of course.
I'm going to respond to 3 problems.
I. NPCs Crashing When Clicked
II. 1st Job Magician Advancement Not Working
III. 2nd Job Magician Advancement Not Working
I. NPCs Crashing When Clicked
*NOTE* This guide applies to when ALL the NPCs are combined in one .CPP file. Also, I would've put my fixed files, but I want you guys to do the work (plus I have some extra npc->giveItem codes).
The Problem: You D/C when you click the NPCs. You will be sent back to the login screen.
Here is the fix.
#1. Open up the file you use for the Job NPCs. For me, it's 1st2ndJob.cpp.
#2. Go to "Edit -> Find and Replace -> Replace In Files". In
Find What, put "if" (without the quotations). In
Replace With, put "else if" (without the quotations). In
Look In, put "Current Document". Once you're done, press "Replace All".
#3. You aren't done yet. Now compile and build your server. You will then get a bunch of errors. One by one, click the errors and fix them. What you need to pay attention to is the conditions (if's and else if's).
If it shows "else if", then change it back to "if". If it shows "else else if", then remove one of the else's. Here's an example.
INCORRECT CODE
Code:
//Thief dungeon npc
void NPCsScripts::npc_1072007(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
else if(state == 0){
else if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show master Dark Lord that you have passed.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(102040000);
npc->end();
}
}
CORRECT CODE
Code:
//Thief dungeon npc
void NPCsScripts::npc_1072007(NPC* npc){
Player* player = npc->getPlayer();
int state = npc->getState();
if(state == 0){
if(npc->getItemAmount(4031013) >= 30){
npc->addText("You are stronger than I thought. I'll give you a medal to show master Dark Lord that you have passed.");
npc->sendNext();
}
else{
npc->addText("You aren't quite finished yet.");
npc->sendOK();
npc->end();
}
}
else if(state == 1){
npc->giveItem(4031013, - npc->getItemAmount(4031013));
npc->giveItem(4031012, 1);
npc->teleport(102040000);
npc->end();
}
}
#4. When you're finished correcting the conditions (if's & else if's), check your text. Make sure your texts are correct. You don't want them to show, for example, "Welcome to Perion! Are you here to b
else ifecome a warrior?"
This will fix the crashes when you click the NPCs.
II. 1st Job Magician Advancement Not Working
The Problem: When you talk to Grendel, he asks whether you want to become a magician or not. When you choose "Yes", nothing will happen.
Here is the fix.
#1. Go down to the "Grendel the Really Old" section. NPC ID = 1032001
#2. Find "if(player->getLevel() == 10){". It should be Line 417.
#3. Replace it with this code.
Code:
if(player->getLevel() >= 8){
This will allow you to become a 1st job magician. The old code only allowed level 10, but this fix will allow levels 8 & up to become a magician.
III. 2nd Job Magician Advancement Not Working
The Problem: If you used my 1st job fix, you will encounter 2nd job advancement problems. The problem is that it will not give you the letter. Instead, it will just make you a 1st job magician again.
Here is the fix.
#1. Go back down to the "Grendel the Really Old" Section. NPC ID = 1032001
#2.
If you used my 1st job fix, look for "if(player->getLevel() >= 8){".
If you DID NOT use my 1st job fix, look for "if(player->getLevel() == 10){". (Either way this will use my 1st job fix.)
#3. Replace that line with the following code.
Code:
if(player->getLevel() >= 8 && player->getLevel() <= 29){
This will prevent the server from making you a 1st job magician. Although this will fix 2nd job magician advancement, anyone over level 29 cannot become a magician anymore.
Hope this helps. For the NPC Crash Fix, I want you guys to work =).