Register for your free account! | Forgot your password?

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

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

Advertisement



[Request] The save for the Inventory after converting into ini.

Discussion on [Request] The save for the Inventory after converting into ini. within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old 01/19/2009, 13:35   #16
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 912
Alright, well since I made a mistake in my first post, I'll make it up to you.

Pack:
Code:
        public void PackInventory()
        {
            if (!MyClient.There)
                return;
            Ready = false;

            Inv1 = "";
            Inv2 = "";
            Inv3 = "";
            Inv4 = "";
            Inv5 = "";
            Inv6 = "";
            Inv7 = "";
            Inv8 = "";

            try
            {
                int count = 0;
                foreach (string item in Inventory)
                {
                    if (item != null && item != "")
                    {
                        if (count >= 0 && count <= 4)
                        {
                            if (count < 4)
                                Inv1 += item + ":";
                            else if (count == 4)
                                Inv1 += item;
                        }
                        if (count >= 5 && count <= 9)
                        {
                            if (count < 9)
                                Inv2 += item + ":";
                            else if (count == 9)
                                Inv2 += item;
                        }
                        else if (count >= 10 && count <= 14)
                        {
                            if (count < 14)
                                Inv3 += item + ":";
                            else if (count == 14)
                                Inv3 += item;
                        }
                        if (count >= 15 && count <= 19)
                        {
                            if (count < 19)
                                Inv4 += item + ":";
                            else if (count == 19)
                                Inv4 += item;
                        }
                        if (count >= 20 && count <= 24)
                        {
                            if (count < 24)
                                Inv5 += item + ":";
                            else if (count == 24)
                                Inv5 += item;
                        }
                        if (count >= 25 && count <= 29)
                        {
                            if (count < 29)
                                Inv6 += item + ":";
                            else if (count == 29)
                                Inv6 += item;
                        }
                        if (count >= 30 && count <= 34)
                        {
                            if (count < 34)
                                Inv7 += item + ":";
                            else if (count == 34)
                                Inv7 += item;
                        }
                        if (count >= 35 && count <= 39)
                        {
                            if (count < 39)
                                Inv8 += item + ":";
                            else if (count == 39)
                                Inv8 += item;
                        }
                        count++;
                    }
                    else
                        break;
                }
            }
            catch (Exception E)
            {
                General.WriteLine(E.ToString());
            }
            Ready = true;
        }
UnPack:
Code:
public void UnPackInventory()
        {
            Ready = false;

            PackedInventory = Inv1 + ":" + Inv2 + ":" + Inv3 + ":" + Inv4 + ":" + Inv5 + ":" + Inv6 + ":" + Inv7 + ":" + Inv8;

            string[] Items = PackedInventory.Split(':');

            int count = 0;

            foreach (string item in Items)
            {
                if (item != null)
                    if (item.Length > 1)
                    {
                        AddItem(item, 0, (uint)General.Rand.Next(10000000));
                        count++;
                    }
                    else
                        break;
            }
            Ready = true;
        }
The Ini file would be setup like this:
Code:
[Inventory]
Inv1=
Inv2=
Inv3=
Inv4=
Inv5=
Inv6=
Inv7=
Inv8=
Save:
Code:
                Save.IniWriteValue("Inventory", "Inv1", Charr.Inv1);
                Save.IniWriteValue("Inventory", "Inv2", Charr.Inv2);
                Save.IniWriteValue("Inventory", "Inv3", Charr.Inv3);
                Save.IniWriteValue("Inventory", "Inv4", Charr.Inv4);
                Save.IniWriteValue("Inventory", "Inv5", Charr.Inv5);
                Save.IniWriteValue("Inventory", "Inv6", Charr.Inv6);
                Save.IniWriteValue("Inventory", "Inv7", Charr.Inv7);
                Save.IniWriteValue("Inventory", "Inv8", Charr.Inv8);
Don't forget to define:
Code:
        public string Inv1 = "";
        public string Inv2 = "";
        public string Inv3 = "";
        public string Inv4 = "";
        public string Inv5 = "";
        public string Inv6 = "";
        public string Inv7 = "";
        public string Inv8 = "";
kinshi88 is offline  
Thanks
1 User
Old 01/19/2009, 15:12   #17
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
@alexbigfoot if you aint here to help then GTFO

@kinshi where excatly should i put those ?in database or character.cs?? cause i know tao's code goes into database.cs but i cant define ReadString can you help me with that ?? thank you
culo01 is offline  
Old 01/19/2009, 15:25   #18
 
_Emme_'s Avatar
 
elite*gold: 1142
Join Date: Aug 2006
Posts: 2,464
Received Thanks: 1,161
Search for:
Quote:
public string IniReadValue(string Section, string Key)
Above that, add:

Quote:
public string ReadString(string Section, string Key, string _Default)
{
return this.ReadString(Section, Key, _Default, 255);
}

public string ReadString(string Section, string Key, string _Default, int BufSize)
{
StringBuilder Buffer = new StringBuilder(BufSize);
GetPrivateProfileStringA(Section, Key, _Default, Buffer, BufSize, this.FileName);
return Buffer.ToString();
}

Note: That was from now on a public code, havent seen (with my eyes, im sure alot have it ) a source so far using ReadString method.
_Emme_ is offline  
Thanks
1 User
Old 01/19/2009, 15:39   #19
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
thanks for your help Emme but i got this errors when i did what you said i should do.
Attached Images
File Type: jpg Untitled.jpg (26.2 KB, 18 views)
culo01 is offline  
Old 01/19/2009, 17:10   #20
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
I've said before, I don't do my inventory like that, it saves just fine on one line.
Then again, I'm not using writestring(or whatever you guys are using).
tao4229 is offline  
Old 01/20/2009, 03:06   #21
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
@kinshi can you please help me ... where i am suppose to put your codes ?

Code:
public static void SaveInventory(Character Charr)
        {
            Ini Cli = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + Charr.Name + ".xml");
                 Cli.WriteString("Character", "Inventory", Convert.ToString(Charr.PackedInventory));
                 Cli.WriteString("Inventory", "Inv1", Convert.ToString(Charr.Inv1));
                 Cli.WriteString("Inventory", "Inv2", Convert.ToString(Charr.Inv2));
                 Cli.WriteString("Inventory", "Inv3", Convert.ToString(Charr.Inv3));
                 Cli.WriteString("Inventory", "Inv4", Convert.ToString(Charr.Inv4));
                 Cli.WriteString("Inventory", "Inv5", Convert.ToString(Charr.Inv5));
                 Cli.WriteString("Inventory", "Inv6", Convert.ToString(Charr.Inv6));
                 Cli.WriteString("Inventory", "Inv7", Convert.ToString(Charr.Inv7));
                 Cli.WriteString("Inventory", "Inv8", Convert.ToString(Charr.Inv8));
        }
culo01 is offline  
Old 01/20/2009, 04:03   #22
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
Quote:
Originally Posted by culo01 View Post
@kinshi can you please help me ... where i am suppose to put your codes ?

Code:
public static void SaveInventory(Character Charr)
        {
            Ini Cli = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + Charr.Name + ".xml");
                 Cli.WriteString("Character", "Inventory", Convert.ToString(Charr.PackedInventory));
                 Cli.WriteString("Inventory", "Inv1", Convert.ToString(Charr.Inv1));
                 Cli.WriteString("Inventory", "Inv2", Convert.ToString(Charr.Inv2));
                 Cli.WriteString("Inventory", "Inv3", Convert.ToString(Charr.Inv3));
                 Cli.WriteString("Inventory", "Inv4", Convert.ToString(Charr.Inv4));
                 Cli.WriteString("Inventory", "Inv5", Convert.ToString(Charr.Inv5));
                 Cli.WriteString("Inventory", "Inv6", Convert.ToString(Charr.Inv6));
                 Cli.WriteString("Inventory", "Inv7", Convert.ToString(Charr.Inv7));
                 Cli.WriteString("Inventory", "Inv8", Convert.ToString(Charr.Inv8));
        }
& quit now.
InfamousNoone is offline  
Old 01/20/2009, 04:14   #23
 
taylor2846's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
xD database.cs
taylor2846 is offline  
Old 01/20/2009, 04:18   #24
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
Quote:
Originally Posted by InfamousNoone View Post
& quit now.
why post when you aint ganna help ?
culo01 is offline  
Old 01/20/2009, 04:42   #25
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
Quote:
Originally Posted by culo01 View Post
why post when you aint ganna help ?
So your post is helpful?

According to you, you shouldn't post if it's not helpful.

/fail.
tao4229 is offline  
Old 01/20/2009, 18:59   #26
 
taylor2846's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
ok il help u out some
in character.cs search for
Code:
public string PackedInventory = ""
under it put in
Code:
        public string Inv1 = "";
        public string Inv2 = "";
        public string Inv3 = "";
        public string Inv4 = "";
        public string Inv5 = "";
        public string Inv6 = "";
        public string Inv7 = "";
        public string Inv8 = "";
then search for
Code:
public void PackInventory()
and replace that void with
Code:
        public void PackInventory()
        {
            if (!MyClient.There)
                return;
            Ready = false;

            Inv1 = "";
            Inv2 = "";
            Inv3 = "";
            Inv4 = "";
            Inv5 = "";
            Inv6 = "";
            Inv7 = "";
            Inv8 = "";

            try
            {
                int count = 0;
                foreach (string item in Inventory)
                {
                    if (item != null && item != "")
                    {
                        if (count >= 0 && count <= 4)
                        {
                            if (count < 4)
                                Inv1 += item + ":";
                            else if (count == 4)
                                Inv1 += item;
                        }
                        if (count >= 5 && count <= 9)
                        {
                            if (count < 9)
                                Inv2 += item + ":";
                            else if (count == 9)
                                Inv2 += item;
                        }
                        else if (count >= 10 && count <= 14)
                        {
                            if (count < 14)
                                Inv3 += item + ":";
                            else if (count == 14)
                                Inv3 += item;
                        }
                        if (count >= 15 && count <= 19)
                        {
                            if (count < 19)
                                Inv4 += item + ":";
                            else if (count == 19)
                                Inv4 += item;
                        }
                        if (count >= 20 && count <= 24)
                        {
                            if (count < 24)
                                Inv5 += item + ":";
                            else if (count == 24)
                                Inv5 += item;
                        }
                        if (count >= 25 && count <= 29)
                        {
                            if (count < 29)
                                Inv6 += item + ":";
                            else if (count == 29)
                                Inv6 += item;
                        }
                        if (count >= 30 && count <= 34)
                        {
                            if (count < 34)
                                Inv7 += item + ":";
                            else if (count == 34)
                                Inv7 += item;
                        }
                        if (count >= 35 && count <= 39)
                        {
                            if (count < 39)
                                Inv8 += item + ":";
                            else if (count == 39)
                                Inv8 += item;
                        }
                        count++;
                    }
                    else
                        break;
                }
            }
            catch (Exception E)
            {
                General.WriteLine(E.ToString());
            }
            Ready = true;
        }
then search for
Code:
public void UnPackInventory()
and replace that void with
Code:
        public void UnPackInventory()
        {
            Ready = false;
            if (PackedInventory.Length < 1)
                return;

            string[] Items = PackedInventory.Split('.');

            int count = 0;

            foreach (string item in Items)
            {
                if (item != null)
                    if (item.Length > 1)
                    {
                        AddItem(item, 0, (uint)General.Rand.Next(10000000));
                        count++;
                    }
                    else
                        break;
            }
            Ready = true;
        }
then go to database.cs and search for
Code:
public static void SaveChar(Character Charr)
and replace
Code:
Cli.WriteString("Character", "Inventory",Charr.PackedInventory);
with

Code:
                Cli.WriteString("Character", "Inv1", Convert.ToString(Charr.Inv1));
                Cli.WriteString("Character", "Inv2", Convert.ToString(Charr.Inv2));
                Cli.WriteString("Character", "Inv3", Convert.ToString(Charr.Inv3));
                Cli.WriteString("Character", "Inv4", Convert.ToString(Charr.Inv4));
                Cli.WriteString("Character", "Inv5", Convert.ToString(Charr.Inv5));
                Cli.WriteString("Character", "Inv6", Convert.ToString(Charr.Inv6));
                Cli.WriteString("Character", "Inv7", Convert.ToString(Charr.Inv7));
                Cli.WriteString("Character", "Inv8", Convert.ToString(Charr.Inv8));
in GetCharInfo search for
Code:
                Charr.PackedInventory = CharacterInfo.ReadValue("Character", "Inventory");
and replace it with
Code:
                Charr.Inv1 = CharacterInfo.ReadValue("Character", "Inv1");
                Charr.Inv2 += CharacterInfo.ReadValue("Character", "Inv2");
                Charr.Inv3 += CharacterInfo.ReadValue("Character", "Inv3");
                Charr.Inv4 += CharacterInfo.ReadValue("Character", "Inv4");
                Charr.Inv5 += CharacterInfo.ReadValue("Character", "Inv5");
                Charr.Inv6 += CharacterInfo.ReadValue("Character", "Inv6");
                Charr.Inv7 += CharacterInfo.ReadValue("Character", "Inv7");
                Charr.Inv8 += CharacterInfo.ReadValue("Character", "Inv8");
then go to
Code:
public static bool CreateCharacter
and replace
Code:
  Create.WriteString("Character", "Inventory", "");
with
Code:
                Create.WriteString("Character", "Inv1", "");
                Create.WriteString("Character", "Inv2", "");
                Create.WriteString("Character", "Inv3", "");
                Create.WriteString("Character", "Inv4", "");
                Create.WriteString("Character", "Inv5", "");
                Create.WriteString("Character", "Inv6", "");
                Create.WriteString("Character", "Inv7", "");
                Create.WriteString("Character", "Inv8", "");
NOTE: not my work its kinshi88 work i just showing how to us it
taylor2846 is offline  
Thanks
1 User
Old 01/20/2009, 20:07   #27
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
Actually, you don't need to write "" to the keys during create character..
tao4229 is offline  
Old 01/20/2009, 21:52   #28
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,882
My post is very helpful, why try when failure is inevitable? If you think I'm wrong, please feel free to prove me wrong.

This is exactly to what I did to the people who didn't think I'd be able to do it when I first started
InfamousNoone is offline  
Old 01/20/2009, 22:20   #29
 
taylor2846's Avatar
 
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
Quote:
Originally Posted by InfamousNoone View Post
My post is very helpful, why try when failure is inevitable? If you think I'm wrong, please feel free to prove me wrong.

This is exactly to what I did to the people who didn't think I'd be able to do it when I first started
ok i dont fail becaz im not here to mack a pserver im here to larn and look at codes and have fun so i can not fail at what im doing xD
taylor2846 is offline  
Old 01/21/2009, 17:03   #30
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
Quote:
Originally Posted by taylor2846 View Post
ok il help u out some
in character.cs search for
Code:
public string PackedInventory = ""
under it put in
Code:
        public string Inv1 = "";
        public string Inv2 = "";
        public string Inv3 = "";
        public string Inv4 = "";
        public string Inv5 = "";
        public string Inv6 = "";
        public string Inv7 = "";
        public string Inv8 = "";
then search for
Code:
public void PackInventory()
and replace that void with
Code:
        public void PackInventory()
        {
            if (!MyClient.There)
                return;
            Ready = false;

            Inv1 = "";
            Inv2 = "";
            Inv3 = "";
            Inv4 = "";
            Inv5 = "";
            Inv6 = "";
            Inv7 = "";
            Inv8 = "";

            try
            {
                int count = 0;
                foreach (string item in Inventory)
                {
                    if (item != null && item != "")
                    {
                        if (count >= 0 && count <= 4)
                        {
                            if (count < 4)
                                Inv1 += item + ":";
                            else if (count == 4)
                                Inv1 += item;
                        }
                        if (count >= 5 && count <= 9)
                        {
                            if (count < 9)
                                Inv2 += item + ":";
                            else if (count == 9)
                                Inv2 += item;
                        }
                        else if (count >= 10 && count <= 14)
                        {
                            if (count < 14)
                                Inv3 += item + ":";
                            else if (count == 14)
                                Inv3 += item;
                        }
                        if (count >= 15 && count <= 19)
                        {
                            if (count < 19)
                                Inv4 += item + ":";
                            else if (count == 19)
                                Inv4 += item;
                        }
                        if (count >= 20 && count <= 24)
                        {
                            if (count < 24)
                                Inv5 += item + ":";
                            else if (count == 24)
                                Inv5 += item;
                        }
                        if (count >= 25 && count <= 29)
                        {
                            if (count < 29)
                                Inv6 += item + ":";
                            else if (count == 29)
                                Inv6 += item;
                        }
                        if (count >= 30 && count <= 34)
                        {
                            if (count < 34)
                                Inv7 += item + ":";
                            else if (count == 34)
                                Inv7 += item;
                        }
                        if (count >= 35 && count <= 39)
                        {
                            if (count < 39)
                                Inv8 += item + ":";
                            else if (count == 39)
                                Inv8 += item;
                        }
                        count++;
                    }
                    else
                        break;
                }
            }
            catch (Exception E)
            {
                General.WriteLine(E.ToString());
            }
            Ready = true;
        }
then search for
Code:
public void UnPackInventory()
and replace that void with
Code:
        public void UnPackInventory()
        {
            Ready = false;
            if (PackedInventory.Length < 1)
                return;

            string[] Items = PackedInventory.Split('.');

            int count = 0;

            foreach (string item in Items)
            {
                if (item != null)
                    if (item.Length > 1)
                    {
                        AddItem(item, 0, (uint)General.Rand.Next(10000000));
                        count++;
                    }
                    else
                        break;
            }
            Ready = true;
        }
then go to database.cs and search for
Code:
public static void SaveChar(Character Charr)
and replace
Code:
Cli.WriteString("Character", "Inventory",Charr.PackedInventory);
with

Code:
                Cli.WriteString("Character", "Inv1", Convert.ToString(Charr.Inv1));
                Cli.WriteString("Character", "Inv2", Convert.ToString(Charr.Inv2));
                Cli.WriteString("Character", "Inv3", Convert.ToString(Charr.Inv3));
                Cli.WriteString("Character", "Inv4", Convert.ToString(Charr.Inv4));
                Cli.WriteString("Character", "Inv5", Convert.ToString(Charr.Inv5));
                Cli.WriteString("Character", "Inv6", Convert.ToString(Charr.Inv6));
                Cli.WriteString("Character", "Inv7", Convert.ToString(Charr.Inv7));
                Cli.WriteString("Character", "Inv8", Convert.ToString(Charr.Inv8));
in GetCharInfo search for
Code:
                Charr.PackedInventory = CharacterInfo.ReadValue("Character", "Inventory");
and replace it with
Code:
                Charr.Inv1 = CharacterInfo.ReadValue("Character", "Inv1");
                Charr.Inv2 += CharacterInfo.ReadValue("Character", "Inv2");
                Charr.Inv3 += CharacterInfo.ReadValue("Character", "Inv3");
                Charr.Inv4 += CharacterInfo.ReadValue("Character", "Inv4");
                Charr.Inv5 += CharacterInfo.ReadValue("Character", "Inv5");
                Charr.Inv6 += CharacterInfo.ReadValue("Character", "Inv6");
                Charr.Inv7 += CharacterInfo.ReadValue("Character", "Inv7");
                Charr.Inv8 += CharacterInfo.ReadValue("Character", "Inv8");
then go to
Code:
public static bool CreateCharacter
and replace
Code:
  Create.WriteString("Character", "Inventory", "");
with
Code:
                Create.WriteString("Character", "Inv1", "");
                Create.WriteString("Character", "Inv2", "");
                Create.WriteString("Character", "Inv3", "");
                Create.WriteString("Character", "Inv4", "");
                Create.WriteString("Character", "Inv5", "");
                Create.WriteString("Character", "Inv6", "");
                Create.WriteString("Character", "Inv7", "");
                Create.WriteString("Character", "Inv8", "");
NOTE: not my work its kinshi88 work i just showing how to us it
its not saving :S i am missing something ??/
culo01 is offline  
Reply


Similar Threads Similar Threads
[Request] Pills in inventory
04/13/2010 - 12Sky2 - 2 Replies
I was wondering if there was some kind of hack to where if the player runs out of pills in the hotkeys, the program will use the pills inside of the inventory OR drag them to the hot keys some how.
[Request]Save Houses
01/25/2010 - CO2 Private Server - 3 Replies
I followed the guide from pringle http://www.*************/forum/conqu...65-houses.h tml seemed 4botters wil be **** i give the link also as a code: Code: http://www.*************/forum/conquer-private-se rvers/7896-5165-houses.html replace *** with 4botters. com to make houses working, but now is my question how to get them saving when shutting down the server. i followed a guide here to save halos, i tried to make houses save the same way but i could't get it working. if anyone is...
[Request] Save conquer 2.0!!
05/25/2009 - Conquer Online 2 - 4 Replies
many people have had their clients freeze randomly since 5127, the problem is the chat system and enlightenment icons freeze them, whenever they get whispered or w.e they freeze, someone PLS make an edit to change the chat system back to normal!! SAVE CONQUER PLAYERS EVERYWHERE!!! :mad:



All times are GMT +2. The time now is 15:44.


Powered by vBulletin®
Copyright ©2000 - 2024, 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 ©2024 elitepvpers All Rights Reserved.