|
You last visited: Today at 11:12
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.
01/19/2009, 04:01
|
#1
|
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));
}
|
|
|
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]
|
|
|
01/19/2009, 04:19
|
#3
|
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
|
Quote:
Originally Posted by tao4229
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?
|
|
|
01/19/2009, 05:09
|
#4
|
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
|
Quote:
Originally Posted by justprownage
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.
|
|
|
01/19/2009, 05:15
|
#5
|
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
|
Quote:
Originally Posted by HellCo
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.
|
|
|
01/19/2009, 05:20
|
#6
|
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
|
Quote:
Originally Posted by justprownage
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.
|
|
|
01/19/2009, 05:24
|
#7
|
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
|
Quote:
Originally Posted by HellCo
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.
|
|
|
01/19/2009, 05:26
|
#8
|
elite*gold: 0
Join Date: Jan 2009
Posts: 212
Received Thanks: 14
|
Quote:
Originally Posted by justprownage
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.
|
|
|
01/19/2009, 05:28
|
#9
|
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
|
Quote:
Originally Posted by HellCo
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.
|
|
|
01/19/2009, 05:31
|
#10
|
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.
|
|
|
01/19/2009, 05:33
|
#11
|
elite*gold: 0
Join Date: May 2008
Posts: 203
Received Thanks: 87
|
Quote:
Originally Posted by HellCo
Don't call someone a noob after they tried to help you, it'll get you nowhere.
|
Sure my friend.
|
|
|
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?
|
|
|
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)
|
|
|
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.
|
|
|
01/19/2009, 07:33
|
#15
|
elite*gold: 0
Join Date: Oct 2008
Posts: 342
Received Thanks: 66
|
Quote:
Originally Posted by alexbigfoot
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.
|
|
|
|
|
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.
|
|