[QUESTION] Make this load in ini

05/25/2009 01:53 Pete1990#1
Well im trying to make my Portals load ini from my debug can someoen help me with this?


public static void LoadPortals()
{
MySqlCommand Command = new MySqlCommand("SELECT * FROM `portals`;", Connection);
MySqlDataAdapter Adapter = new MySqlDataAdapter(Command);
DataSet DS = new DataSet("Count");
Adapter.Fill(DS, "Count");
if (DS.Tables["Count"].Rows.Count > 0)
{
int Portal = DS.Tables["Count"].Rows.Count;

Portals = new ushort[Portal][];
for (int i = 0; i < DS.Tables["Count"].Rows.Count; i++)
{
DataRow Data = DS.Tables["Count"].Rows[i];
Portals[i] = new ushort[6] { Convert.ToUInt16((uint)Data["FromMap"]), Convert.ToUInt16((uint)Data["FromX"]), Convert.ToUInt16((uint)Data["FromY"]), Convert.ToUInt16((uint)Data["NewMap"]), Convert.ToUInt16((uint)Data["NewX"]), Convert.ToUInt16((uint)Data["NewY"]) };
}
}
}
05/25/2009 01:56 justprownage#2
Check Infamous' source. It shows you exactly how.
05/25/2009 02:34 Pete1990#3
ok i tried that but its not wokring becuse id ont have those files and if i try and add them boom:D crashes and btw this is lotf source im useing.
public static void LoadPortals()
{
string LoadPortals= System.IO.File.ReadAllText(System.Windows.Forms.Ap plication.StartupPath + @"\Portals.ini");
DataSet DS = new DataSet("Count");
Ini.Fill(DS, "Count");
if (DS.Tables["Count"].Rows.Count > 0)
{
int Portal = DS.Tables["Count"].Rows.Count;

Portals = new ushort[Portal][];
for (int i = 0; i < DS.Tables["Count"].Rows.Count; i++)
{
DataRow Data = DS.Tables["Count"].Rows[i];
Portals[i] = new ushort[6] { Convert.ToUInt16((uint)Data["FromMap"]), Convert.ToUInt16((uint)Data["FromX"]), Convert.ToUInt16((uint)Data["FromY"]), Convert.ToUInt16((uint)Data["NewMap"]), Convert.ToUInt16((uint)Data["NewX"]), Convert.ToUInt16((uint)Data["NewY"]) };
}
}
}
05/25/2009 02:36 PeTe Ninja#4
change string BannedIP to string Portals
05/25/2009 02:38 Pete1990#5
Yea i seent hat still dont work lol
05/25/2009 02:47 justprownage#6
It's supposed to write the string. You still have this whole part:
Code:
DataSet DS = new DataSet("Count");
Ini.Fill(DS, "Count");
if (DS.Tables["Count"].Rows.Count > 0)
{
int Portal = DS.Tables["Count"].Rows.Count;

Portals = new ushort[Portal][];
for (int i = 0; i < DS.Tables["Count"].Rows.Count; i++)
{
DataRow Data = DS.Tables["Count"].Rows[i];
Portals[i] = new ushort[6] { Convert.ToUInt16((uint)Data["FromMap"]), Convert.ToUInt16((uint)Data["FromX"]), Convert.ToUInt16((uint)Data["FromY"]), Convert.ToUInt16((uint)Data["NewMap"]), Convert.ToUInt16((uint)Data["NewX"]), Convert.ToUInt16((uint)Data["NewY"]) };
This code interacts with the SQL database. You need to re-code this.
05/25/2009 02:50 Pete1990#7
:O just forget it i dont knwo how to do that lmao.
05/25/2009 04:00 CptSky#8
Code:
        public static void LoadPortals()
        {
            try
            {
                int PortalsC = 0;

                string[] PortalsInfo = File.ReadAllLines(Application.StartupPath + @"\Portals.txt");

                Portals = new ushort[PortalsInfo.Length][];

                for (int i = 0; i < PortalsInfo.Length; i++)
                {
                    string[] Splitter = PortalsInfo[i].Split(' ');

                    //FromMap, FromX, FromY, ToMap, ToX, ToY
                    Portals[i] = new ushort[6] { ushort.Parse(Splitter[0]), ushort.Parse(Splitter[1]), ushort.Parse(Splitter[2]), ushort.Parse(Splitter[3]), ushort.Parse(Splitter[4]), ushort.Parse(Splitter[5]) };
                    PortalsC++;
                }
                General.WriteLine("Loaded " + PortalsC + " portals.");
            }
            catch (Exception Exc) { General.WriteLine(Exc.ToString()); }
        }
05/25/2009 04:42 Pete1990#9
Thank you so much this might be pushing it but do u have the portal.txt u can post:D
05/25/2009 14:24 IcedEarth#10
Here Pete.