You last visited: Today at 11:13
Advertisement
[HELP]ini files for npcs
Discussion on [HELP]ini files for npcs within the CO2 Private Server forum part of the Conquer Online 2 category.
11/10/2008, 01:05
#1
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
[HELP]ini files for items
Ty for your all help
how wold i setup for items??
11/10/2008, 01:10
#2
elite*gold: 0
Join Date: Dec 2007
Posts: 618
Received Thanks: 213
Code:
public static void LoadNPCs()
{
try
{
string[] ENpc = File.ReadAllLines(System.Windows.Forms.Application.StartupPath + @"\gets\npcs.ini");
NPCs = new uint[ENpc.Length][];
for (int ik = 0; ik < ENpc.Length; ik++)
{
string[] a = ENpc[ik].Split('#');
NPCs[ik] = new uint[8] { uint.Parse(a[0]), uint.Parse(a[1]), uint.Parse(a[3]), uint.Parse(a[4]), uint.Parse(a[5]), uint.Parse(a[6]), uint.Parse(a[7]), uint.Parse(a[8]) };
}
Console.Write("NPCs Loaded from DataBase: " + ENpc.Length + "\n");
passednpcs = true;
}
catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); passednpcs = false; }
}
the thing i`m using.
Attached Files
npcs.rar
(6.6 KB, 23 views)
11/10/2008, 01:26
#3
elite*gold: 0
Join Date: Aug 2007
Posts: 469
Received Thanks: 94
ty dude i was just aking for help but this works and saves me lots of time so ty dude no im gona go start working on the rest of my files to ini files
11/10/2008, 01:36
#4
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
Code:
public static string LoadNpcs
{
get
{
string[] StrDelimiter = File.ReadAllLines(DBFolder + "\\Npc\\Spawns.txt");
Npcs = new ConquerNpc[StrDelimiter.Length];
for (uint i = 0; i < StrDelimiter.Length; i++)
Npcs[i] = ConquerNpc.Parse(StrDelimiter[i]);
return string.Format("\tLoaded {0} Npcs.", Npcs.Length);
}
}
Haydz wins?
11/10/2008, 05:07
#5
elite*gold: 0
Join Date: Jun 2007
Posts: 387
Received Thanks: 64
Actually, the way LOTF handles the NPC's is probably the most efficient. MYSQL only made the server unstable when it was required to keep an active connection to the server at all times. As players made changes to characters, the way the MYSQL connection was coded, the more unstable the server became. This was the source of the login error. C# reads from a MYSQL database faster than from flat files(most of the time, depending on the coding and the coder...), and in LOTF loading all non-changing entities from the MYSQL database increased the speed of the loading, and reduced overall memory usage. If your going to use flat files, you should only convert the characters, accounts, guilds, and friends to text files. This is strictly a personal opinion, as others may and will have different views, but I believe this is the most efficient way to write a server source.
11/10/2008, 09:05
#6
elite*gold: 0
Join Date: Dec 2007
Posts: 618
Received Thanks: 213
Quote:
Originally Posted by
© Haydz
Code:
public static string LoadNpcs
{
get
{
string[] StrDelimiter = File.ReadAllLines(DBFolder + "\\Npc\\Spawns.txt");
Npcs = new ConquerNpc[StrDelimiter.Length];
for (uint i = 0; i < StrDelimiter.Length; i++)
Npcs[i] = ConquerNpc.Parse(StrDelimiter[i]);
return string.Format("\tLoaded {0} Npcs.", Npcs.Length);
}
}
Haydz wins?
probabily
, after all, i`m not a genius
11/10/2008, 13:25
#7
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
I intend to use .txt and .ini files for my new source the whole way through .
But from the looks of the first post it reads 1 value from each key and does nothing? Wtf? ._.
11/10/2008, 14:59
#8
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Quote:
Originally Posted by
© Haydz
Code:
public static string LoadNpcs
{
get
{
string[] StrDelimiter = File.ReadAllLines(DBFolder + "\\Npc\\Spawns.txt");
Npcs = new ConquerNpc[StrDelimiter.Length];
for (uint i = 0; i < StrDelimiter.Length; i++)
Npcs[i] = ConquerNpc.Parse(StrDelimiter[i]);
return string.Format("\tLoaded {0} Npcs.", Npcs.Length);
}
}
Haydz wins?
Not really, your still using strings at the end of the day which requires alot more processing...so no.
11/10/2008, 15:45
#9
elite*gold: 0
Join Date: Feb 2008
Posts: 277
Received Thanks: 52
Quote:
public static void LoadNpcs()
{
string[] NPCFile = File.ReadAllLines(DB + "\\Instance\\NPC.txt");
foreach (string Content in NPCFile)
{
string[] NPCArray = Content.Split(' ');
NPCInstance Npc = new NPCInstance();
Npc.UID = Convert.ToUInt32(NPCArray[0]);
Npc.ID = Convert.ToUInt32(NPCArray[1]);
Npc.PosX = Convert.ToUInt16(NPCArray[2]);
Npc.PosY = Convert.ToUInt16(NPCArray[3]);
Npc.Type = Convert.ToUInt16(NPCArray[4]);
Npc.Direction = Convert.ToUInt16(NPCArray[5]);
Npc.Flag = Convert.ToUInt32(NPCArray[6]);
Npc.MapID = Convert.ToUInt16(NPCArray[7]);
SpawnNPCPack Spawn = new SpawnNPCPack();
Spawn.Npc = Npc;
Spawn.BuildPacket();
Spawn.SpawnNPCPack = Spawn.PacketData;
World.AllNpcs.Add(Npc.UID, Npc);
}
}
A bit like haydz ;D
11/10/2008, 16:34
#10
elite*gold: 0
Join Date: Feb 2008
Posts: 668
Received Thanks: 160
I can't equip any items anymore =( Someone knows how comes? ( I'm using Ini's )
11/10/2008, 16:51
#11
elite*gold: 20
Join Date: Jan 2008
Posts: 1,042
Received Thanks: 252
Quote:
Originally Posted by
Korvacs
Not really, your still using strings at the end of the day which requires alot more processing...so no.
The competion was between the other 2 pieces of code.
11/10/2008, 20:34
#12
elite*gold: 0
Join Date: Feb 2008
Posts: 668
Received Thanks: 160
Quote:
Originally Posted by
YukiXian
I can't equip any items anymore =( Someone knows how comes? ( I'm using Ini's )
*Edit : Found out my Source doesn't load my Ini items. how to load them?
I'f got this :
Code:
public static void LoadItems()
{
string[] Item = File.ReadAllLines(System.Windows.Forms.Application.StartupPath + @"\Others\AllItems.ini");
DBItems = new string[Item.Length][];
for (int i = 0; i < Item.Length; i++)
{
string[] Splitter = Item[i].Split('-');
//Items[i] = new uint[15] { uint.Parse(Splitter[0]), uint.Parse(Splitter[1]), uint.Parse(Splitter[2]), uint.Parse(Splitter[3]), uint.Parse(Splitter[4]), uint.Parse(Splitter[5]), uint.Parse(Splitter[6]), uint.Parse(Splitter[7]), uint.Parse(Splitter[8]), uint.Parse(Splitter[9]), uint.Parse(Splitter[10]), uint.Parse(Splitter[11]), uint.Parse(Splitter[12]), uint.Parse(Splitter[13]), uint.Parse(Splitter[14]), uint.Parse(Splitter[15]) };
DBItems[i] = new string[16] { Splitter[0], Splitter[1], uint.Parse(Splitter[2]), uint.Parse(Splitter[3]), uint.Parse(Splitter[4]), uint.Parse(Splitter[5]), uint.Parse(Splitter[6]), uint.Parse(Splitter[7]), uint.Parse(Splitter[8]), uint.Parse(Splitter[9]), uint.Parse(Splitter[10]), uint.Parse(Splitter[11]), uint.Parse(Splitter[12]), uint.Parse(Splitter[13]), uint.Parse(Splitter[14]), uint.Parse(Splitter[15]) };
}
Console.WriteLine("Loaded all items.");
Similar Threads
Fling mount data base files and sever files
03/07/2010 - EO PServer Hosting - 15 Replies
well i think i have found the flying mounts so if u guys want to have a look here is the link for u to download the database files and all the other stuff u need for it
Free File Hosting Made Simple - MediaFire
Cerdits to 4fcom
Good luck
All times are GMT +1. The time now is 11:13 .