Character settings for 5165

02/14/2010 22:09 copz1337#1
This is why I like use Navicat for mySql better lol.. how can I make it so that when a new char is made and he logs in he will have, let's say 50 cps?
02/14/2010 22:12 Arcо#2
Quote:
Originally Posted by copz1337 View Post
This is why I like use Navicat for mySql better lol.. how can I make it so that when a new char is made and he logs in he will have, let's say 50 cps?
Go to the createchar place in database.cs and make the default cps amount 50.
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"))
                {
                    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);//Avatar
                        else
                            BW.Write((ushort)201);//Avatar

                        BW.Write(Body);
                        BW.Write((ushort)(410 + (Program.Rnd.Next(5) * 100)));//Hair
                        BW.Write((ushort)1010);//Map
                        BW.Write((ushort)61);//X
                        BW.Write((ushort)109);//Y
                        BW.Write((ushort)0);//Previous Map
                        BW.Write(Job);
                        BW.Write((byte)0);//Previous Job, 1st RB
                        BW.Write((byte)1);//Level
                        BW.Write((ulong)0);//Experience

                        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);//Stat Points
                        ushort HP = (ushort)(Vit * 24 + Str * 3 + Agi * 3 + Spi * 3);
                        BW.Write(HP);
                        BW.Write((ushort)(Spi * 5));//MP
                        BW.Write((ulong)0);//Donation
                        BW.Write((uint)100);//Silvers
[SIZE="5"][COLOR="Red"][B][I][U]                        BW.Write((uint)0);//CPs[/U][/I][/B][/COLOR][/SIZE]
                        BW.Write((uint)0);//Warehouse Silvers
                        BW.Write((ulong)0);//Virtue Points
                        BW.Write((ushort)0);//PK Points
                        BW.Write((ushort)0);//Guild
                        BW.Write((uint)0);//Guild Donation
                        BW.Write((byte)0);//Guild Rank
                        Game.Equipment Eq = new NewestCOServer.Game.Equipment();
                        Eq.Open();
                        Eq.WriteThis(BW);
                        BW.Write((byte)5);//Inventory Count
                        #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);//SkillCount
                        else
                        {
                            BW.Write((byte)2);//SkillCount
                            Game.Skill S = new Game.Skill() { ID = 1000 };
                            S.WriteThis(BW);
                            S = new Game.Skill() { ID = 1005 };
                            S.WriteThis(BW);
                        }

                        BW.Write((byte)0);//Friend Count
                        BW.Write((byte)0);//Enemy Count
                        

                        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);//Merchant
                        BW.Write(0);//  
                        BW.Write(DateTime.Now.Ticks);
                        BW.Write((ushort)0);
                        BW.Write(false);
                        BW.Write((byte)0);//lottery uses today
                        BW.Write("0");//WH Pass
                        BW.Write("None");//Spouse Name
                        BW.Write((uint)0);//Quiz Pts       
                        BW.Write((int)0);//TopEffect
                        BW.Write(false);//ClaimGW
                        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."; }
        }
    }
02/14/2010 22:55 copz1337#3
Thanks Arco.
02/15/2010 04:15 Arcо#4
Np, anytime you need help, don't hesitate to pm me.