Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 18:07

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



5165 Save or Load Character Problem.

Discussion on 5165 Save or Load Character Problem. within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
5165 Save or Load Character Problem.

alright so IDK wtf I did 2 dis source dat now wen I login and log out my character doesnt save sumhow and like his/her gears are all fucked up wen u login again like...a necklace is where da armor should be at lol...and da armor is like da weapon...so on...only like 3 things save...

well I'm hoping I can get answers from dis...I'll post my SaveCharacter/LoadCharacter void here...

Code:
public static Game.Character LoadCharacter(string Name, ref string Account)
        {
            try
            {
                Game.Character C = new CoSX.Game.Character();
                if (File.Exists(@"C:\CoSX\Database\Users\Characters\" + Name + ".chr"))
                {
                    FileStream FS = new FileStream(@"C:\CoSX\Database\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 CoSX.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.PreviousJob1 = 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 CoSX.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 CoSX.Game.Item();
                        I.ReadThis(BR);
                        C.Inventory.Add(I);
                    }
                    C.Warehouses = new CoSX.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 CoSX.Game.Skill();
                        S.ReadThis(BR);
                        C.Skills.Add(S.ID, S);
                        if (S.ID == 3060)
                            C.CanReflect = true;
                    }

                    C.Profs = new Hashtable();
                    byte ProfCount = BR.ReadByte();
                    for (byte i = 0; i < ProfCount; i++)
                    {
                        Game.Prof P = new CoSX.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 CoSX.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 CoSX.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.TripleExp = BR.ReadBoolean();
                        C.TripleExpLeft = BR.ReadInt32();
                        C.QuadrupleExp = BR.ReadBoolean();
                        C.QuadrupleExpLeft = 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 = (CoSX.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();
                        C.VipMapToday = BR.ReadByte();
                        C.VotedToday = BR.ReadByte();
                        C.ClaimGWWinnings = BR.ReadByte();

                        try
                        {
                            C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                            if (C.WHPassword.Length == 0)
                                C.WHPassword = "";
                        }
                        catch { C.WHPassword = ""; C.UniversityPoints = 0; }

                        try
                        {
                            C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                            C.UniversityPoints = BR.ReadUInt32();
                            C.HunterName = BR.ReadString();
                            C.MonsterHunter = BR.ReadInt32();
                            C.MHunter = BR.ReadBoolean(); 
                            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 = "";
                            C.Spouse = "None";
                            C.UniversityPoints = 0;
                            C.HunterName = "Default";
                            C.MonsterHunter = 0;
                            C.MHunter = false; 
                            C.VipMapToday = 0;
                            C.ClaimGWWinnings = 0;
                            C.VotedToday = 0;
                        }
                    }
                    catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                    FS.Flush();
                    BR.Close();
                    FS.Close();
                    C.Loaded = true;
                }
                return C;
            }
            catch (Exception Exc) { Console.WriteLine(Exc); return null; }
        }
Code:
public static void SaveCharacter(Game.Character C, string Acc)
        {
            try
            {
                FileStream FS = new FileStream(@"C:\CoSX\Database\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;
                int TripleExp = C.TripleExpLeft;
                if (C.TripleExp)
                    TripleExp -= (int)(DateTime.Now - C.ExpPotionUsed).TotalSeconds;
                int QuadrupleExp = C.QuadrupleExpLeft;
                if (C.QuadrupleExp)
                    QuadrupleExp -= (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.PreviousJob1);//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.TripleExp);
                BW.Write(TripleExp);
                BW.Write(C.QuadrupleExp);
                BW.Write(QuadrupleExp);
                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.VipMapToday);
                BW.Write(C.ClaimGWWinnings);
                BW.Write(C.VotedToday);
                BW.Write(C.WHPassword);
                BW.Write(C.Spouse);
                BW.Write(C.UniversityPoints);//Quiz Pts 
                BW.Write(C.HunterName);//Quest
                BW.Write(C.MonsterHunter);//Quest
                BW.Write(C.MHunter);//Quest 
                BW.Write(C.Top);

                BW.Flush();
                FS.Flush();
                BW.Close();
                FS.Close();
            }
            catch (Exception Exc) { Console.WriteLine(Exc); }
        }
Regards,
killersub
killersub is offline  
Old 07/29/2010, 03:54   #2
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
so there's no help with this problem?
killersub is offline  
Old 07/29/2010, 04:06   #3
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
have you tried replace it with the old save/load, so nothing is changed?
Fish* is offline  
Old 07/29/2010, 04:43   #4
 
killersub's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 884
Received Thanks: 211
Quote:
Originally Posted by grillmad View Post
have you tried replace it with the old save/load, so nothing is changed?
well as u see in da SaveCharacter void I added also 10x and 20x exp potions (TripleExp and QuadrupleExp) IDK if dats da prob...
also I added da save for MonsterHunter quest...

In da LoadCharacter I have da same **** lol...idk if DATS it...but wat do U suggest?
killersub is offline  
Old 07/29/2010, 07:44   #5
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
Try add 1 after 1.
Then u can see wich one makes the problem
Fish* is offline  
Old 07/29/2010, 22:27   #6
 
elite*gold: 0
Join Date: Feb 2007
Posts: 340
Received Thanks: 38
you probably deleted some rows of coding...idk where it is..i know i did this and everything screwed up....
solution:
started all over again (i kno it sucks)

also i don't know if this is what you did...i'm just guessing
ryuchetval is offline  
Reply


Similar Threads Similar Threads
Character load fix :D
12/22/2010 - Shaiya - 4 Replies
OK for those of you who get the EP4 character Data Load Error.... Make sure you have these done in order DOWNLOAD US SHAIYA (IF YOU ALREADY HAVE IT CHECK HERE) C://Aeria Games/Shaiya <---Standard instalation path Copy and paste that SHAIYA FOLDER somewhere else for instance if u have 2 hard drives D://Programs/Shaiya (rename it to EuroEP4) <--saves time
5165 Character creation problem
07/30/2010 - CO2 Private Server - 10 Replies
when i create a new account using /newacc test test and log in with it the character has like 100+ rbs and it increases every character i make can anyone help?
5165 character creating problem.
01/01/2010 - CO2 Private Server - 0 Replies
Ok, so, recently i made my server online,its just for fun, nothing big or stuff like that,but, appearantly the other ppl got a problem. After they create an account on site, they log in, create the character, and you get dc after you create it, as we all know, but, when they relog to play, they are sent back to character creation,but when i make an account from cmd window, it works fine. so pls a little help , Thank you very much!



All times are GMT +1. The time now is 18:08.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.