5165 Character creation problem

07/29/2010 00:46 Zkiller110#1
when i create a new account using /newacc test test [PM] and log in with it the character has like 100+ rbs and it increases every character i make can anyone help?
07/29/2010 01:21 killersub#2
go into ur character.cs file and find/post here ur LoadCharacter and SaveCharacter void and post it here...letz c wat da prob iz...
07/29/2010 04:08 Fish*#3
isn't it database.cs?
07/29/2010 04:54 Zkiller110#4
yes its in the database.cs here's my load character

Code:
        public static Game.Character LoadCharacter(string Name, ref string Account)
        {
            try
            {
                Game.Character C = new NewestCOServer.Game.Character();
                if (File.Exists(@"C:\OldCODB\Users\Characters\" + Name + ".chr"))
                {
                    FileStream FS = new FileStream(@"C:\OldCODB\Users\Characters\" + Name + ".chr", FileMode.Open);
                    BinaryReader BR = new BinaryReader(FS);
                    C.Name = Name;
                    Account = BR.ReadString();
                    C.EntityID = BR.ReadUInt32();
                    C.Avatar = BR.ReadUInt16();
                    C.Body = BR.ReadUInt16();
                    C.Hair = BR.ReadUInt16();

                    C.Loc = new NewestCOServer.Game.Location();
                    C.Loc.Map = BR.ReadUInt16();
                    C.Loc.X = BR.ReadUInt16();
                    C.Loc.Y = BR.ReadUInt16();
                    C.Loc.PreviousMap = BR.ReadUInt16();

                    C.Job = BR.ReadByte();
                    C.PreviousJob = BR.ReadByte();
                    C.Level = BR.ReadByte();
                    C.Experience = BR.ReadUInt64();

                    C.Str = BR.ReadUInt16();
                    C.Agi = BR.ReadUInt16();
                    C.Vit = BR.ReadUInt16();
                    C.Spi = BR.ReadUInt16();
                    C.StatPoints = BR.ReadUInt16();
                    C.CurHP = BR.ReadUInt16();
                    C.CurMP = BR.ReadUInt16();
                    C.Nobility.Donation = BR.ReadUInt64();

                    C.Nobility.ListPlace = -1;
                    if (C.Nobility.Donation >= 3000000)
                    {
                        C.Nobility.ListPlace = 50;
                        for (int i = 49; i >= 0; i--)
                        {
                            if (C.Nobility.Donation >= Game.World.EmpireBoard[i].Donation)
                                C.Nobility.ListPlace--;
                        }
                        if (C.Nobility.ListPlace < 50)
                        {
                            if (C.Nobility.Donation >= 30000000 && C.Nobility.Donation <= 100000000)
                                C.Nobility.Rank = Game.Ranks.Knight;
                            else if (C.Nobility.Donation >= 100000000 && C.Nobility.Donation <= 200000000)
                                C.Nobility.Rank = Game.Ranks.Baron;
                            else if (C.Nobility.Donation >= 200000000 && C.Nobility.Donation <= 300000000)
                                C.Nobility.Rank = Game.Ranks.Earl;
                            else if (C.Nobility.ListPlace >= 15 && C.Nobility.ListPlace <= 50)
                                C.Nobility.Rank = Game.Ranks.Duke;
                            else if (C.Nobility.ListPlace >= 3 && C.Nobility.ListPlace <= 15)
                                C.Nobility.Rank = Game.Ranks.Prince;
                            else if (C.Nobility.ListPlace <= 3)
                                C.Nobility.Rank = Game.Ranks.King;
                        }
                    }

                    C.Silvers = BR.ReadUInt32();
                    C.CPs = BR.ReadUInt32();
                    C.WHSilvers = BR.ReadUInt32();
                    C.VP = BR.ReadUInt64();
                    C.PKPoints = BR.ReadUInt16();
                    ushort GID = BR.ReadUInt16();

                    if (Features.Guilds.AllTheGuilds.Contains(GID))
                    {
                        C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];

                        uint Don = BR.ReadUInt32(); ;
                        byte GR = BR.ReadByte();
                        if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
                        {
                            C.GuildDonation = Don;
                            C.GuildRank = (Features.GuildRank)GR;

                            C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
                            C.MembInfo.Level = C.Level;
                            C.GuildDonation = C.MembInfo.Donation;
                            C.GuildRank = C.MembInfo.Rank;
                        }
                        else
                            C.MyGuild = null;
                    }
                    else BR.ReadBytes(5);

                    C.Equips = new NewestCOServer.Game.Equipment();
                    C.Equips.ReadThis(BR);
                    C.Inventory = new ArrayList(40);
                    byte InventoryCount = BR.ReadByte();
                    for (byte i = 0; i < InventoryCount; i++)
                    {
                        Game.Item I = new NewestCOServer.Game.Item();
                        I.ReadThis(BR);
                        C.Inventory.Add(I);
                    }
                    C.Warehouses = new NewestCOServer.Game.Banks();
                    C.Warehouses.ReadThis(BR);

                    C.Skills = new Hashtable();
                    byte SkillCount = BR.ReadByte();
                    for (byte i = 0; i < SkillCount; i++)
                    {
                        Game.Skill S = new NewestCOServer.Game.Skill();
                        S.ReadThis(BR);
                        C.Skills.Add(S.ID, S);
                    }

                    C.Profs = new Hashtable();
                    byte ProfCount = BR.ReadByte();
                    for (byte i = 0; i < ProfCount; i++)
                    {
                        Game.Prof P = new NewestCOServer.Game.Prof();
                        P.ReadThis(BR);
                        if (!C.Profs.Contains(P.ID))
                            C.Profs.Add(P.ID, P);
                    }

                    C.Friends = new Hashtable();
                    byte FriendCount = BR.ReadByte();
                    for (byte i = 0; i < FriendCount; i++)
                    {
                        Game.Friend F = new NewestCOServer.Game.Friend();
                        F.ReadThis(BR);
                        if (!C.Friends.Contains(F.UID))
                            C.Friends.Add(F.UID, F);
                    }

                    C.Enemies = new Hashtable();
                    byte EnemyCount = BR.ReadByte();
                    for (byte i = 0; i < EnemyCount; i++)
                    {
                        Game.Enemy E = new NewestCOServer.Game.Enemy();
                        E.ReadThis(BR);
                        if (!C.Enemies.Contains(E.UID))
                            C.Enemies.Add(E.UID, E);
                    }
                    try
                    {
                        C.DoubleExp = BR.ReadBoolean();
                        C.DoubleExpLeft = BR.ReadInt32();
                        C.BlessingLasts = BR.ReadInt32();
                        C.BlessingStarted = DateTime.FromBinary(BR.ReadInt64());

                        C.LuckyTime = BR.ReadUInt32();
                        C.ExpBallsUsedToday = BR.ReadByte();
                        C.Reborns = BR.ReadByte();
                        C.Merchant = (NewestCOServer.Game.MerchantTypes)BR.ReadByte();
                        C.VipLevel = BR.ReadByte();
                        try
                        {
                            C.LastLogin = DateTime.FromBinary(BR.ReadInt64());
                        }
                        catch { C.LastLogin = DateTime.Now; }
                        C.TrainTimeLeft = BR.ReadUInt16();
                        C.InOTG = BR.ReadBoolean();
                        C.LotteryUsed = BR.ReadByte();

                        try
                        {
                            C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));

                            if (!C.MyClient.ValidWHPass(C.WHPassword))
                                C.WHPassword = "0";
                        }
                        catch { C.WHPassword = "0"; C.UniversityPoints = 0; }

                        try
                        {
                            C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                            C.UniversityPoints = BR.ReadUInt32();
                            C.Top = BR.ReadInt32();
                        }
                        catch
                        {
                            C.VipLevel = 0;
                            C.ExpBallsUsedToday = 0;
                            C.LotteryUsed = 0;
                            C.TrainTimeLeft = 0;
                            C.InOTG = false;
                            C.LotteryUsed = 0;
                            C.WHPassword = "0";
                            C.Spouse = "None";
                            C.UniversityPoints = 0; 
                        }
                    }
                    catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                    FS.Flush();
                    BR.Close();
                    FS.Close();
                    C.Loaded = true;
                    if (C.Top == 1)
                    {

                    }
                }
                return C;
            }
            catch (Exception Exc) { Console.WriteLine(Exc); return null; }
        }
and my save character

Code:
       public static void SaveCharacter(Game.Character C, string Acc)
        {
            try
            {
                FileStream FS = new FileStream(@"C:\OldCODB\Users\Characters\" + C.Name + ".chr", FileMode.Open);
                BinaryWriter BW = new BinaryWriter(FS);

                int DoubleExp = C.DoubleExpLeft;
                if (C.DoubleExp)
                    DoubleExp -= (int)(DateTime.Now - C.ExpPotionUsed).TotalSeconds;

                BW.Write(Acc);
                BW.Write(C.EntityID);
                BW.Write(C.Avatar);
                BW.Write(C.Body);
                BW.Write(C.Hair);//Hair
                BW.Write(C.Loc.Map);//Map
                BW.Write(C.Loc.X);//X
                BW.Write(C.Loc.Y);//Y
                BW.Write(C.Loc.PreviousMap);//Previous Map
                BW.Write(C.Job);
                BW.Write(C.PreviousJob);//Previous Job, 1st RB
                BW.Write(C.Level);//Level
                BW.Write(C.Experience);//Experience        
                BW.Write(C.Str);
                BW.Write(C.Agi);
                BW.Write(C.Vit);
                BW.Write(C.Spi);
                BW.Write(C.StatPoints);//Stat Points
                BW.Write(C.CurHP);
                BW.Write(C.CurMP);//MP
                BW.Write(C.Nobility.Donation);
                BW.Write(C.Silvers);//Silvers
                BW.Write(C.CPs);
                BW.Write(C.WHSilvers);//Warehouse Silvers
                BW.Write(C.VP);//Virtue Points
                BW.Write(C.PKPoints);//PK Points
                if (C.MyGuild != null)
                {
                    BW.Write(C.MyGuild.GuildID);//Guild
                    BW.Write(C.GuildDonation);//Guild Donation
                    BW.Write((byte)C.GuildRank);//Guild Rank
                }
                else BW.Write(new byte[7]);
                C.Equips.WriteThis(BW);
                BW.Write((byte)C.Inventory.Count);
                foreach (Game.Item I in C.Inventory)
                    I.WriteThis(BW);
                C.Warehouses.WriteThis(BW);
                BW.Write((byte)C.Skills.Count);
                foreach (Game.Skill I in C.Skills.Values)
                    I.WriteThis(BW);
                BW.Write((byte)C.Profs.Count);
                foreach (Game.Prof I in C.Profs.Values)
                    I.WriteThis(BW);
                BW.Write((byte)C.Friends.Count);
                foreach (Game.Friend I in C.Friends.Values)
                    I.WriteThis(BW);
                BW.Write((byte)C.Enemies.Count);
                foreach (Game.Enemy I in C.Enemies.Values)
                    I.WriteThis(BW);

                BW.Write(C.DoubleExp);
                BW.Write(DoubleExp);
                BW.Write(C.BlessingLasts);
                BW.Write(C.BlessingStarted.Ticks);
                if (C.GettingLuckyTime)
                {
                    if (!C.Prayer)
                        C.LuckyTime += (uint)(DateTime.Now - C.PrayDT).TotalSeconds;
                    else
                        C.LuckyTime += (uint)(DateTime.Now - C.PrayDT).TotalSeconds * 3;
                    C.PrayDT = DateTime.Now;
                }
                BW.Write(C.LuckyTime);
                BW.Write(C.ExpBallsUsedToday);
                BW.Write(C.Reborns);
                BW.Write((byte)C.Merchant);// 
                BW.Write(C.VipLevel);//   
                BW.Write(DateTime.Now.Ticks);//When logged off, for otg feature purposes
                BW.Write((ushort)(C.TrainTimeLeft + ((DateTime.Now - C.LoggedOn).TotalMinutes * 10)));//Train time left (in minutes)
                BW.Write(C.InOTG);
                BW.Write(C.LotteryUsed);
                BW.Write(C.WHPassword);
                BW.Write(C.Spouse);
                BW.Write(C.UniversityPoints);//Quiz Pts 
                BW.Write(C.Top);

                if (C.MyClient != null && C.MyClient.AuthInfo.Status != "[GM]" && C.MyClient.AuthInfo.Status != "[PM]")
                {

                    BW.Flush();
                    FS.Flush();
                    BW.Close();
                    FS.Close();
                }
            }
            catch (Exception Exc) { Console.WriteLine(Exc); }
        }
07/29/2010 05:04 Fish*#5
What about CreateCharacter?
07/29/2010 05:39 Zkiller110#6
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)0);//Silvers
                        BW.Write((uint)0);//CPs
                        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
                        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);//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.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;
                            C.Top = 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."; }
        }
07/29/2010 07:45 Fish*#7
Is it when u create, or when u leave birthvillage?
07/29/2010 07:53 Zkiller110#8
when i create character
07/29/2010 08:21 Fish*#9
What source are u using exactly?
I know is 5165, but wich one of them?
07/29/2010 08:35 Zkiller110#10
im uploading my source right now got 2 hours yet im not sure what 1 it is exactly on elitepvpers ive went through many of them ill send you link of my source when its uploaded
07/30/2010 01:26 Zkiller110#11
Problem Fixed #request close