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:
Code:
public static string CreateCharacter(string Account, string Name, ushort Body, byte Job)
{
if (Job == 50)
{
return ("Ninja is not allowed. Pick another class.");
}
try
{
if (File.Exists(@"C:\OldCODB\Users\" + Account + ".usr") && !File.Exists(@"C:\OldCODB\Users\Characters\" + Name + ".chr"))
{
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: Character already exists!";
}
catch (Exception Exc) { Console.WriteLine(Exc); return "Failed to create the character."; }
}
}
The code I added is at the very top, under the first line,
Code:
if (Job == 50)
{
return ("Ninja is not allowed. Pick another class.");
}
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?