Register for your free account! | Forgot your password?

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

  • 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   #1
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
[Request] The save for the Inventory after converting into ini.

Does anyone know how to make the Inventory save all the items? Because when ever I disconnect or restart the server, the items in my inventory disappears.
This is what I have so far:
Code:
public static void SaveInventory(Character Charr)
        {
            Ini Cli = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + Charr.Name + ".chr");
            Cli.WriteString("Character", "Inventory", Convert.ToString(Charr.PackedInventory));
        }
justprownage is offline  
Old 01/19/2009, 04:18   #2
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
Okay, so people stfu about this...

Code:
[color=black]
[color=blue]public static void[/color] SaveInventory([color=mediumturquoise]Character[/color] Character)
{
    [color=mediumturquoise]Ini[/color] IniFile = [color=blue]new[/color] [color=mediumturquoise]Ini[/color]([color=darkred]@"\Database\Characters"[/color] + Character.Name + [color=darkred]".ini"[/color]);[color=green]//fix db path if you want..[/color]
    [color=blue]for[/color]([color=blue]byte[/color] i = 1; i < Character.Inventory.Length; i++)
    {
        IniFile.WriteString([color=darkred]"Character"[/color],[color=darkred]"Inventory["[/color] + i + [color=darkred]"]"[/color], Character.Inventory[i]);
    }
}

[color=blue]public static void[/color] LoadInventory([color=mediumturquoise]Character[/color] Char)
{
     [color=mediumturquoise]Ini[/color] IniFile = [color=blue]new[/color] [color=mediumturquoise]Ini[/color]([color=darkred]@"\Database\Characters"[/color] + Char.Name + [color=darkred]".ini"[/color]);[color=green]//fix db path if you want yet again.[/color]
     Char.Inventory = [color=blue]new[/color] [color=blue]string[/color][41];[color=green]//I think LOTF does it like this, fix it if not.[/color]
     [color=blue]for[/color]([color=blue]byte[/color] i = 1; i < Char.Inventory.Length; i++)
     {
           Char.Inventory[i] = Ini.ReadString([color=darkred]"Character"[/color],[color=darkred]"Inventory"[/color]);[color=green]//fix parameters, if you need to specify size etc..[/color]
     }
}
[/color]
tao4229 is offline  
Thanks
2 Users
Old 01/19/2009, 04:19   #3
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
Quote:
Originally Posted by tao4229 View Post
Okay, so people stfu about this...

Code:
[color=black]
[color=blue]public static void[/color] SaveInventory([color=cyan]Character[/color] Character)
{
    [color=cyan]Ini[/color] IniFile = [color=blue]new[/color] [color=cyan]Ini[/color]([color=darkred]@"\Database\Characters"[/color] + Character.Name + [color=darkred]".ini"[/color]);[color=green]//fix db path if you want..[/color]
    [color=blue]for[/color]([color=blue]byte[/color] i = 1; i < Character.Inventory.Length; i++)
    {
        IniFile.WriteString([color=darkred]"Character"[/color],[color=darkred]"Inventory["[/color] + i + [color=darkred]"]"[/color], Character.Inventory[i]);
    }
}

[color=blue]public static void[/color] LoadInventory([color=cyan]Character[/color] Char)
{
     [color=cyan]Ini[/color] IniFile = [color=blue]new[/color] [color=cyan]Ini[/color]([color=darkred]@"\Database\Characters"[/color] + Character.Name + [color=darkred]".ini"[/color]);[color=green]//fix db path if you want yet again.[/color]
     Char.Inventory = [color=blue]new[/color] [color=blue]string[/color][41];[color=green]//I think LOTF does it like this, fix it if not.[/color]
     [color=blue]for[/color]([color=blue]byte[/color] i = 1; i < Char.Inventory.Length; i++)
     {
           Char.Inventory[i] = Ini.ReadString([color=darkred]"Character"[/color],[color=darkred]"Inventory"[/color]);[color=green]//fix parameters, if you need to specify size etc..[/color]
     }
}
[/color]
I want to thanks you a million times xD

#edit
Tested it and it still doesn't save the inventory. Do I have to add something in the GetCharInfo?
justprownage is offline  
Old 01/19/2009, 05:09   #4
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
Quote:
Originally Posted by justprownage View Post
Does anyone know how to make the Inventory save all the items? Because when ever I disconnect or restart the server, the items in my inventory disappears.
This is what I have so far:
Code:
public static void SaveInventory(Character Charr)
        {
            Ini Cli = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + Charr.Name + ".chr");
            Cli.WriteString("Character", "Inventory", Convert.ToString(Charr.PackedInventory));
        }
Bro, just look in other sources that have it working, LOTF have it working, or just use Kinishi's source which xmasterrr released without permission.
HellCo is offline  
Old 01/19/2009, 05:15   #5
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
Quote:
Originally Posted by HellCo View Post
Bro, just look in other sources that have it working, LOTF have it working, or just use Kinishi's source which xmasterrr released without permission.
Those sources arent converted to ini u n00b.
justprownage is offline  
Old 01/19/2009, 05:20   #6
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
Quote:
Originally Posted by justprownage View Post
Those sources arent converted to ini u n00b.
How does this make me a noob please explain,

For one you didnt mension .ini files not once in this thread, you may have in other threads which i yet havent had time to look at yet.

For two, I only tried to help, if you're gonna call everyone a noob that tries to help, *** help you, you'll receive no help.
HellCo is offline  
Old 01/19/2009, 05:24   #7
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
Quote:
Originally Posted by HellCo View Post
How does this make me a noob please explain,

For one you didnt mension .ini files not once in this thread, you may have in other threads which i yet havent had time to look at yet.

For two, I only tried to help, if you're gonna call everyone a noob that tries to help, *** help you, you'll receive no help.
You must be blind. The title says it all.

[Request] The save for the Inventory after converting into ini.
justprownage is offline  
Old 01/19/2009, 05:26   #8
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
Quote:
Originally Posted by justprownage View Post
You must be blind. The title says it all.

[Request] The save for the Inventory after converting into ini.
Ok, sorry, i mis-read, I'll read carefully next time, but still, It gives you no rights to call anybody a noob, after trying to help you.
HellCo is offline  
Old 01/19/2009, 05:28   #9
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
Quote:
Originally Posted by HellCo View Post
Ok, sorry, i mis-read, I'll read carefully next time, but still, It gives you no rights to call anybody a noob, after trying to help you.
n00b = my way of saying dunce
noob on the other hand, know little and have no will to learn any more.
justprownage is offline  
Old 01/19/2009, 05:31   #10
 
HellCo's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
Don't call someone a noob after they tried to help you, it'll get you nowhere.
HellCo is offline  
Old 01/19/2009, 05:33   #11
 
justprownage's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
Wink

Quote:
Originally Posted by HellCo View Post
Don't call someone a noob after they tried to help you, it'll get you nowhere.
Sure my friend.
justprownage is offline  
Old 01/19/2009, 06:41   #12
 
elite*gold: 0
Join Date: Feb 2006
Posts: 100
Received Thanks: 0
ReadString not defined .....any help please?will this fix warehouse too?
culo01 is offline  
Old 01/19/2009, 06:44   #13
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 912
LOTF "packs" the inventory to save it.

Pack:
Code:
        public void PackInventory()
        {
            if (!MyClient.There)
                return;
            Ready = false;
            try
            {
                PackedInventory = "";
                int count = 0;
                foreach (string item in Inventory)
                {
                    if (item != null && item != "")
                    {
                        if (count == 0)
                            PackedInventory += item + ":";
                        else if (count > 0)
                            PackedInventory += ":" + item + ":";
                    }
                    else
                        break;

                }
                if (PackedInventory.Length > 1)
                    PackedInventory = PackedInventory.Remove(PackedInventory.Length - 1, 1);
            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
            Ready = true;
        }
UnPack:
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;
        }
Save:
Code:
                Charr.PackInventory();
                Save.IniWriteValue("Packed", "Inventory", Charr.PackedInventory);
Then call the Unpack in case 74.

(I'm surprised, all of this is default in any LOTF based server... lol)
kinshi88 is offline  
Old 01/19/2009, 07:29   #14
 
elite*gold: 0
Join Date: Dec 2007
Posts: 618
Received Thanks: 213
ok....kinshi if u didnt know ... ur ini is not rdy to save over 256 chars....that needs fixing...or use the Tao`s save n load ,but for noobs, is too hard to put it in their sources.
alexbigfoot is offline  
Old 01/19/2009, 07:33   #15
 
elite*gold: 0
Join Date: Oct 2008
Posts: 342
Received Thanks: 66
Quote:
Originally Posted by alexbigfoot View Post
ok....kinshi if u didnt know ... ur ini is not rdy to save over 256 chars....that needs fixing...or use the Tao`s save n load ,but for noobs, is too hard to put it in their sources.
255 chars not 256

btw a save function is one of the easy things btw i recommend an Array list for inv.
µ~Xero~µ 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 11:12.


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.