[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.
[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));
}
[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]
[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?
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.
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.
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.
[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: