Change your class NPC

07/05/2014 00:57 anone.ious#1
Here is npc [change your class for 1,000,000 CPS!!]
for Source 5165.

k go to NPCDialog.cs and add this:
Code:
 #region ChangeYourClass
                            case 6699:
                                {
                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("Would you like to change your job for 1000000 cps?"));
                                        GC.AddSend(Packets.NPCLink("Sure!", 1));
                                        GC.AddSend(Packets.NPCLink("No thanks.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }

                                    else if (Control == 1)
                                    {

                                        GC.AddSend(Packets.NPCSay("Alright choose the job. [for 1000000 cps]"));
                                        GC.AddSend(Packets.NPCLink("Trojan", 3));
                                        GC.AddSend(Packets.NPCLink("Warrior", 4));
                                        GC.AddSend(Packets.NPCLink("Archer", 5));
                                        GC.AddSend(Packets.NPCLink("WaterTaoist", 6));
                                        GC.AddSend(Packets.NPCLink("FireTaoist", 7));
                                        GC.AddSend(Packets.NPCLink("Ninja", 8));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());

                                    }

                                     if (Control == 3)
                                        if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 15;
                                        }
                                     if (Control == 4)
                                        if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 25;
                                        }
                                     if (Control == 5)
                                        if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 45;
                                        }
                                     if (Control == 6)
                                         if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 135;
                                        }
                                     if (Control == 7)
                                         if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 145;
                                        }
                                     if (Control == 8)
                                         if (GC.MyChar.Job >= 15 && GC.MyChar.CPs >= 1000000)
                                        {
                                            GC.MyChar.CPs -= 1000000;
                                            GC.MyChar.Job = 55;
                                        }
                                    break;
                                }
                            #endregion
and now go to NPCS.txt on your OLDCOOB folder and add this in the bottom
Code:
 6699 9200 2 67 1002 443 361
NOTE: if you want change the cps just change the GC.MyChar.CPs -= 1000000; [1000000 is the cps just change it if you want..]
if i helped to you press on the Thanks button :)
07/05/2014 09:02 Spirited#2
A switch statement may be a better option than what you have going on. Actually, a nested if-else statement would be better than what you have as well. Having to check every if statement (like what you have above) will cost you.
07/05/2014 11:29 turk55#3
So you have to be a Trojan Master or anything else ?

EDIT: I was bored so here is a better approach, not sure if it will work with the source you use though but you should get the idea.

Code:
case 6699:
{
	if (Control == 0)
	{
		GC.AddSend(Packets.NPCSay("Would you like to change your job for 1000000 cps?"));
		GC.AddSend(Packets.NPCLink("Sure!", 1));
		GC.AddSend(Packets.NPCLink("No thanks.", 255));
	} 
	else if (Control == 1)
	{ 
		GC.AddSend(Packets.NPCSay("Alright choose the job. [for 1000000 cps]"));
		GC.AddSend(Packets.NPCLink("Trojan", 15));
		GC.AddSend(Packets.NPCLink("Warrior", 25));
		GC.AddSend(Packets.NPCLink("Archer", 45));
		GC.AddSend(Packets.NPCLink("WaterTaoist", 135));
		GC.AddSend(Packets.NPCLink("FireTaoist", 145));
		GC.AddSend(Packets.NPCLink("Ninja", 55));
	}
	if(Control > 1) {
		if(GC.MyChar.CPs >= 1000000) {
			GC.MyChar.CPs -= 1000000;
			GC.MyChar.Job = Control;
			GC.AddSend(Packets.NPCSay("Your class has been changed."));
			GC.AddSend(Packets.NPCLink("Thanks", 255)); 
		} else {
			GC.AddSend(Packets.NPCSay("You don't meet the requirements."));
			GC.AddSend(Packets.NPCLink("My bad", 255)); 
		}
	}
	GC.AddSend(Packets.NPCSetFace(N.Avatar));
	GC.AddSend(Packets.NPCFinish()); 
	break;
}
07/07/2014 13:55 Best Coder 2014#4
If there's someone out there who actually needs this or finds this useful, they shouldn't be coding a private server at all.
07/08/2014 04:59 InsomniacPro#5
Code:
            case 6699:
    switch(Control)
{

        case 0:
		GC.AddSend(Packets.NPCSay("Would you like to change your job for 1000000 cps?"));
		GC.AddSend(Packets.NPCLink("Sure!", 1));
		GC.AddSend(Packets.NPCLink("No thanks.", 255));
	
            break;
        case 1:
		GC.AddSend(Packets.NPCSay("Alright choose the job. [for 1000000 cps]"));
		GC.AddSend(Packets.NPCLink("Trojan", 15));
		GC.AddSend(Packets.NPCLink("Warrior", 25));
		GC.AddSend(Packets.NPCLink("Archer", 45));
		GC.AddSend(Packets.NPCLink("WaterTaoist", 135));
		GC.AddSend(Packets.NPCLink("FireTaoist", 145));
		GC.AddSend(Packets.NPCLink("Ninja", 55));
        default:
		if(GC.MyChar.CPs >= 1000000)
                 {
			GC.MyChar.CPs -= 1000000;
			GC.MyChar.Job = Control;
			GC.AddSend(Packets.NPCSay("Your class has been changed."));
			GC.AddSend(Packets.NPCLink("Thanks", 255)); 
             break;		  
                 }
			GC.AddSend(Packets.NPCSay("You don't meet the requirements."));
			GC.AddSend(Packets.NPCLink("My bad", 255)); 
		
            break;
	}
	GC.AddSend(Packets.NPCSetFace(N.Avatar));
	GC.AddSend(Packets.NPCFinish()); 
	break;
}
07/08/2014 05:30 Spirited#6
As I said in my previous post, an if-else statement would be the most efficient conditional structure for this scenario. It's not large enough for a switch statement to become more efficient.

Code:
if (Control == 0)
{

}
else if (Control == 1)
{

}
else
{

}
07/08/2014 06:18 InsomniacPro#7
Quote:
Originally Posted by Spirited View Post
As I said in my previous post, an if-else statement would be the most efficient conditional structure for this scenario. It's not large enough for a switch statement to become more efficient.

Code:
if (Control == 0)
{

}
else if (Control == 1)
{

}
else
{

}
But switches look sooooooo much neater!
07/08/2014 06:42 InfamousNoone#8
Quote:
Originally Posted by Spirited View Post
As I said in my previous post, an if-else statement would be the most efficient conditional structure for this scenario. It's not large enough for a switch statement to become more efficient.

Code:
if (Control == 0)
{

}
else if (Control == 1)
{

}
else
{

}
there's no need to micro-optimize the performance loss is negligible if a switch-statement were actually generated, secondly the compiler is smart enough to produce an if-statement if the switch statement is "inefficiently small."
07/08/2014 07:06 Spirited#9
Quote:
Originally Posted by InfamousNoone View Post
there's no need to micro-optimize the performance loss is negligible if a switch-statement were actually generated, secondly the compiler is smart enough to produce an if-statement if the switch statement is "inefficiently small."
So you're saying that you should just rely on your compiler to fix your shit programming practices? That doesn't sound right in the slightest. Sure it's small, but knowing the correct way of doing it can't harm your code.
07/08/2014 13:16 Best Coder 2014#10
Quote:
Originally Posted by Spirited View Post
So you're saying that you should just rely on your compiler to fix your shit programming practices? That doesn't sound right in the slightest. Sure it's small, but knowing the correct way of doing it can't harm your code.
:facepalm:

[Only registered and activated users can see links. Click Here To Register...]

Quote:
This would be much better represented as a switch as it then makes it immediately obviously that the choice of action is occurring based on the value of "value" and not some arbitrary test.
Quote:
If you are switching on the value of a single variable then I'd use a switch every time, it's what the construct was made for.
Edit:
Using a switch might actually be faster than if/else in this specific even if there's only a few branches, if not then at least as fast as if/else.
But let's be honest, only a moron would actually worry about insignificant stuff like this.

Double edit:
Really, you should never ever ever ever ever ever ever think about performance when choosing whether to use switch or if/else ... really, NEVER. That is the stupidest shit I have ever heard.
07/08/2014 16:34 KraHen#11
Here we are again, if vs switch. Lets start a Java bashing and a Python vs. LUA scripting war as well and it`s like the old days.
07/08/2014 17:34 Spirited#12
Quote:
Originally Posted by Best Coder 2014 View Post
:facepalm:

[Only registered and activated users can see links. Click Here To Register...]





Edit:
Using a switch might actually be faster than if/else in this specific even if there's only a few branches, if not then at least as fast as if/else.
But let's be honest, only a moron would actually worry about insignificant stuff like this.

Double edit:
Really, you should never ever ever ever ever ever ever think about performance when choosing whether to use switch or if/else ... really, NEVER. That is the stupidest shit I have ever heard.
That answer was written for an absolute beginner to teach him/her what a switch statement is used for. You can do whatever the hell you want (I'm not telling you want to do), but I do things the way they should be done (you know, the correct way). You can argue your position all you want, but it's still the technically the wrong position.
07/08/2014 17:42 Best Coder 2014#13
Quote:
Originally Posted by Spirited View Post
That answer was written for an absolute beginner to teach him/her what a switch statement is used for. You can do whatever the hell you want (I'm not telling you want to do), but I do things the way they should be done (you know, the correct way). You can argue your position all you want, but it's still the technically the wrong position.
Reality
-
-
-
-
-
-
-
-
-
-
-

You

Really, you couldn't be further away.
07/08/2014 17:53 Spirited#14
Quote:
Originally Posted by Best Coder 2014 View Post
Reality
-
-
-
-
-
-
-
-
-
-
-

You

Really, you couldn't be further away.
As I said, you can do whatever you want (no need to get butt hurt), just don't come here spreading bad programming practices. There's a time to use a switch statement, and the correct time to use it would be to replace larger if-ifelse-else conditional code blocks that share the some conditional identifier.
07/08/2014 18:02 Best Coder 2014#15
Quote:
Originally Posted by Spirited View Post
As I said, you can do whatever you want (no need to get butt hurt), just don't come here spreading bad programming practices. There's a time to use a switch statement, and the correct time to use it would be to replace larger if-ifelse-else conditional code blocks that share the some conditional identifier.
Quote:
If and Switch: When to use Which
Now that if and switch statements have both been explained, it's time to analyze: which is more appropriate in certain situations?

If and switch seem related to each other in the same manner as while and for. Switch statements work well when critiquing the value of a single variable, and save time and space in these situations, just as for provides a more concise and contained way to write count-controlled loops. Furthermore, switch statements and count-controlled loops fit very well together simply due to the nature of their coding.

Just as while allows for broader test statements, so does if when compared to switch. When dealing with difficult logic that spans a plethora of variables, if statements are the most appropriate. They allow for multiple tests to be performed as well as logical comparisons of these test values. If statements can also be nested to allow for critically defined and logically understandable paths of execution.

So, when deciding which statement you should use, simply ask yourself: can I relate all the possible paths of execution to a single variable? If so, then switch is best, as it saves time and is easy to read. If no, then you need to use if, as switch can only handle conditional situations that rely on a single variable.
From [Only registered and activated users can see links. Click Here To Register...]

Do I need to provide more sources, or will you just keep talking shit?