[Request] 5165 Class Ban

01/18/2015 08:17 stormy547#1
Hello to whoever bothers to read this.

I am currently working on the 5165 NCOS and I do not intend to divert from it any time soon.

I am trying to add a ban on ninjas, and I have seen this done in other 5165 servers. I know around where the code is needed, but I don't have the knowledge of what should be added to it.


Any help is welcome. Any comments about downgrading my source will most likely be ignored, or I will give you a reason on why I won't.


**EDIT

Also, if anyone has all of the files for the dragon souls, could you please upload them?
I can't find a download anywhere.
01/20/2015 04:20 stormy547#2
Bump.

I'm assuming that out of 60+ views, nobody even has a comment? 0.o
01/20/2015 05:38 -Sensei-#3
Its easy.. Add a new check..
if(Class ninja)
{
go fuck yourself;
}
01/20/2015 05:53 stormy547#4
I doubt that's the code, for multiple reasons.

1. None of the other code in that area matches,

2. There wouldn't be a "Class" or "Ninja", that I know of,

3. It creates an error when entered, which is fully expected.

4. I know that there are more codes to go around that, especially around the text that pops up when you attempt to create a character.

If you think I am a rookie, you are wrong.

And congratulations at failing to be an asshole.
01/20/2015 06:03 -Sensei-#5
Seriously dude, im trying to help here and i gave you the right answer..

i told you make a check,

if(client class = 50( which is ninja)
{
return message = "Class is not available";
}
01/20/2015 06:23 mujake#6
I believe he was expecting directly the code, not an idea on how to create it himself.
01/20/2015 06:48 stormy547#7
My slight knowledge of C# is in the NPC/Command making area. I can make NPCs, and I can make commands based on other codes in the source, but I do not recognize the codes in the database.cs, I apologize for my earlier comments.

As for the code you gave, I believe it would work, except the source does not recognize "client" "class" and "message"
01/20/2015 06:53 mujake#8
Quote:
Originally Posted by stormy547 View Post
My slight knowledge of C# is in the NPC/Command making area. I can make NPCs, and I can make commands based on other codes in the source, but I do not recognize the codes in the database.cs, I apologize for my earlier comments.

As for the code you gave, I believe it would work, except the source does not recognize "client" "class" and "message"
Just go to the Character creation sections add an line where it checks the class, if it's 50 make it pop up a message telling you are not allowed, i did that while ago and it worked.

It won't require more C# knowledge than making an NPC check ffs.
If (Character.Profession == 50)
{
Message ("You are not allowed to create ninja")
return;
}

Something like this, now look in your source and figure it out, not that had.
01/20/2015 07:53 stormy547#9
So, below

catch { return "Error! Try again."; }
return "ANSWER_OK";
}
return "Error: Character already exists!";

I added:

if (Job == 50)
{
return ("You are not allowed to create ninja");

}

And now, every account, regardless of class, gets the error message "Error! Try again.", and on second attempt, it says "Error: Character already exists!".
It also adds a new char file, with given name. If you try to login with that acc and pass, it takes you back to the character creation.
01/20/2015 11:48 mujake#10
because you are doing it wrong, you have to check for job right before it creates it and sends the answer....
It easy, just try different places every time, it's basic logic here.
01/20/2015 12:18 KraHen#11
Quote:
Originally Posted by stormy547 View Post
I doubt that's the code, for multiple reasons.

1. None of the other code in that area matches,

2. There wouldn't be a "Class" or "Ninja", that I know of,

3. It creates an error when entered, which is fully expected.

4. I know that there are more codes to go around that, especially around the text that pops up when you attempt to create a character.

If you think I am a rookie, you are wrong.
I love epvp. He was trying to help you with a basic pseudocode.

Quote:
And congratulations at failing to be an asshole.
Well, at least you`ve shown him how it`s done!

Quote:
I apologize for my earlier comments
Then again I see hope in you.
01/20/2015 15:56 pro4never#12
We've given you tons of help. We're telling you the logic that needs to be entered in to block a specific character from being created.


Your job is now this.

#1: Locate where characters are created (it will be reading from a packet the client sends)
#2: Determine where in the packet the player's profession is stored (it should be obvious because the source already has to read it)
#3: Check that profession against what is either allowed or banned (in this case ninja profession which is base profession 50... you should really be going with a list of allowed base professions though or I can just spoof a packet and create a max promotion character at lvl 1)
#4: Return an error to the client if they try to create a character with a profession you don't want them able to use
01/20/2015 23:47 stormy547#13
And I thank you all very much for the help you have given me.

I only have one issue left, for some reason now no class can be made. Ninja is fully banned, but I'm not sure if I've left something out of the code I made with your help. Currently the entire creation code is as follows:


The code I added is at the very top, under the first line,


Now the message comes through for "Ninja is not allowed. Pick another class." every single time, without creating a new character. Every other class, it first says "Error! Try again." and then if you try again with the same name, it says "Error: Character already exists!", and the new character that it created has no account, its simply a character created. You can't login with it, and you can spam the database with accounts.

What is missing?
01/21/2015 05:31 -Sensei-#14
try this

Code:
public static string CreateCharacter(string Account, string Name, ushort Body, byte Job)
        {
            try
            {
                if (File.Exists(@"C:\OldCODB\Users\" + Account + ".usr") && !File.Exists(@"C:\OldCODB\Users\Characters\" + Name + ".chr"))
                {
if (Job == 50)
{
                    try
                    {
                        FileStream FS = new FileStream(@"C:\OldCODB\Users\Characters\" + Name + ".chr", FileMode.CreateNew);
                        BinaryWriter BW = new BinaryWriter(FS);
                        BW.Write(Account);
                        BW.Write((uint)Program.Rnd.Next(1000001, 19999999));

                        if (Body == 1003 || Body == 1004)
                            BW.Write((ushort)1);
                        else
                            BW.Write((ushort)201);

                        BW.Write(Body);
                        BW.Write((ushort)(410 + (Program.Rnd.Next(5) * 100)));
                        BW.Write((ushort)1010);
                        BW.Write((ushort)61);
                        BW.Write((ushort)109);
                        BW.Write((ushort)0);
                        BW.Write(Job);
                        BW.Write((byte)0);
                        BW.Write((byte)1);
                        BW.Write((ulong)0);

                        ushort Str = 0, Agi = 0, Vit = 0, Spi = 0;
                        GetInitialStats(Job, ref Str, ref Agi, ref Vit, ref Spi);

                        BW.Write(Str);
                        BW.Write(Agi);
                        BW.Write(Vit);
                        BW.Write(Spi);
                        BW.Write((ushort)0);
                        ushort HP = (ushort)(Vit * 24 + Str * 3 + Agi * 3 + Spi * 3);
                        BW.Write(HP);
                        BW.Write((ushort)(Spi * 5));
                        BW.Write((ulong)0);
                        BW.Write((uint)100);
                        BW.Write((uint)0);
                        BW.Write((uint)0);
                        BW.Write((ulong)0);
                        BW.Write((ushort)0);
                        BW.Write((ushort)0);
                        BW.Write((uint)0);
                        BW.Write((byte)0);
                        Game.Equipment Eq = new NewestCOServer.Game.Equipment();
                        Eq.Open();
                        Eq.WriteThis(BW);
                        BW.Write((byte)5);
                        #region Beginner Items
                        if (Job == 100)
                        {
                            Game.Item I = new NewestCOServer.Game.Item();
                            I.ID = 421301;
                            I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)421301]).Durability;
                            I.CurDur = I.MaxDur;
                            I.UID = (uint)Program.Rnd.Next(10000000);
                            I.WriteThis(BW);
                        }
                        else if (Job == 50)
                        {
                            Game.Item I = new NewestCOServer.Game.Item();
                            I.ID = 601301;
                            I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)601301]).Durability;
                            I.CurDur = I.MaxDur;
                            I.UID = (uint)Program.Rnd.Next(10000000);
                            I.WriteThis(BW);
                        }
                        else
                        {
                            Game.Item I = new NewestCOServer.Game.Item();
                            I.ID = 410301;
                            I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)410301]).Durability;
                            I.CurDur = I.MaxDur;
                            I.UID = (uint)Program.Rnd.Next(10000000);
                            I.WriteThis(BW);
                        }
                        Game.Item Armor = new NewestCOServer.Game.Item();
                        Armor.ID = 132004;
                        Armor.Color = (Game.Item.ArmorColor)(Program.Rnd.Next(3, 9));
                        Armor.MaxDur = ((DatabaseItem)DatabaseItems[(uint)132004]).Durability;
                        Armor.CurDur = Armor.MaxDur;
                        Armor.UID = (uint)Program.Rnd.Next(10000000);
                        Armor.WriteThis(BW);
                        Game.Item Stancher = new NewestCOServer.Game.Item();
                        Stancher.ID = 1000000;
                        Stancher.UID = (uint)Program.Rnd.Next(10000000);
                        Stancher.WriteThis(BW);
                        Stancher.UID = (uint)Program.Rnd.Next(10000000);
                        Stancher.WriteThis(BW);
                        Stancher.UID = (uint)Program.Rnd.Next(10000000);
                        Stancher.WriteThis(BW);
                        #endregion
                        for (int n = 0; n < 5; n++)
                        {
                            BW.Write((byte)0);//WH[n] Count
                            //Warehouse[n]
                        }
                        BW.Write((byte)0);//WH[5] Count
                        //Warehouse[5]

                        BW.Write((byte)0);//Prof Count

                        if (Job != 100)
                            BW.Write((byte)0);
                        else
                        {
                            BW.Write((byte)2);
                            Game.Skill S = new Game.Skill() { ID = 1000 };
                            S.WriteThis(BW);
                            S = new Game.Skill() { ID = 1005 };
                            S.WriteThis(BW);
                        }

                        BW.Write((byte)0);
                        BW.Write((byte)0);


                        BW.Write(false);
                        BW.Write((int)0);
                        BW.Write((int)0);
                        BW.Write((long)0);
                        BW.Write((int)0);
                        BW.Write((byte)0);
                        BW.Write((byte)0);
                        BW.Write((byte)1);
                        BW.Write(0);
                        BW.Write(DateTime.Now.Ticks);
                        BW.Write((ushort)0);
                        BW.Write(false);
                        BW.Write((byte)0);
                        BW.Write("0");
                        BW.Write("None");
                        BW.Write((uint)0);
                        BW.Flush();
                        FS.Flush();

                        BW.Close();
                        FS.Close();
                        FS = new FileStream(@"C:\OldCODB\Users\" + Account + ".usr", FileMode.Append);
                        BW = new BinaryWriter(FS);
                        BW.Write((byte)Name.Length);
                        BW.Write(Encoding.ASCII.GetBytes(Name));
                        BW.Flush();
                        FS.Flush();
                        BW.Close();
                        FS.Close();
                        Game.Character C = LoadCharacter(Name, ref Account);
                        if (C != null)
                        {
                            C.UniversityPoints = 0;
                            SaveCharacter(C, Account);
                        }
                    }
                    catch { return "Error! Try again."; }
                    return "ANSWER_OK";
		   }
		   return "Error: Ninja is not available!";
                }
                return "Error: Character already exists!";

            }
            catch (Exception Exc) { Console.WriteLine(Exc); return "Failed to create the character."; }
        }
    }
01/22/2015 03:47 stormy547#15
Now, Ninja isn't banned, instead every other class is banned with the No Ninja message. Also, Ninja now has that error about the "try again' and then "character already created". I think that this didn't fix anything, but actually reversed the desired effect 0.o