Example #1
0
        public static bool AddScript(db_script script)
        {
            if (scriptList.ContainsKey(script.id))
                return false;

            scriptList.Add(script.id, script);
            return true;
        }
Example #2
0
        public static bool AddScript(db_script script)
        {
            if (scriptList.ContainsKey(script.id))
            {
                return(false);
            }

            scriptList.Add(script.id, script);
            return(true);
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Length == 0)
            {
                MessageBox.Show("The id cannot be blank.");
                return;
            }

            string str = textBox1.Text.Trim();
            Int64  value;
            bool   isNum = Int64.TryParse(str, out value);

            if (!isNum)
            {
                MessageBox.Show("The script id should be a number. Please enter a number.");
                return;
            }

            if (bIsCreature)
            {
                if (Datastores.dbused && !creatures.npcsAvailable.Contains(System.Convert.ToUInt32(textBox1.Text)))
                {
                    MessageBox.Show("This Creature is NOT in creature_template");
                    return;
                }

                creature newcreature = new creature(System.Convert.ToUInt32(textBox1.Text), "");
                if (!creatures.AddCreature(newcreature))
                {
                    MessageBox.Show("ID already Exists!");
                }
                else
                {
                    this.Hide();

                    (this.MdiParent as Hauptfenster).ShowNewForm(newcreature.creature_id);
                    (this.MdiParent as Hauptfenster).UpdateNPCListBox();
                }
            }
            else
            {
                db_script newscript = new db_script(System.Convert.ToUInt32(textBox1.Text));
                if (!db_scripts.AddScript(newscript))
                {
                    MessageBox.Show("ID already Exists!");
                }
                else
                {
                    this.Hide();

                    (this.MdiParent as Hauptfenster).ShowNewForm(newscript.id);
                    (this.MdiParent as Hauptfenster).UpdateNPCListBox();
                }
            }
        }
Example #4
0
        // Preview DB scripts
        public static string WriteScriptToWindow(db_script script, string table)
        {
            if (script == null)
                return "";

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("-- Script id: " + script.id);

            if (table != "event_scripts" && table != "gameobject_scripts" && table != "spell_scripts")
                sb.AppendLine(CreateScriptTemplateQuery(script, false, table));

            sb.AppendLine(SQLcreator.CreateDeleteQuery(script, table));
            sb.AppendLine(SQLcreator.CreateCreateQuery(script, table));

            return sb.ToString();
        }
Example #5
0
        // Create DB script
        public static bool WriteScriptToFile(db_script script, string file, bool reihe, string table)
        {
            if (script == null || script.line.Count == 0)
                return false;

            StreamWriter sqlpatchfile = new StreamWriter(file, reihe);
            sqlpatchfile.WriteLine("-- Script id: " + script.id);

            if (table != "event_scripts" && table != "gameobject_scripts" && table != "spell_scripts")
                sqlpatchfile.WriteLine(CreateScriptTemplateQuery(script, false, table));

            sqlpatchfile.WriteLine(SQLcreator.CreateDeleteQuery(script, table));
            sqlpatchfile.WriteLine(SQLcreator.CreateCreateQuery(script, table));
            sqlpatchfile.Close();
            return true;
        }
Example #6
0
        // Load DB scripts
        public static void LoadDBScripts(string sTable)
        {
            if (!Datastores.dbused)
                return;

            MySqlDataReader reader = null;

            // Check for the creatureAI tables
            try
            {
                string sQuery = "SELECT information_schema.TABLES.table_name FROM information_schema.TABLES " +
                    "where information_schema.TABLES.table_name IN ('creature_movement_scripts','event_script','gameobject_scripts','gossip_scripts','quest_end_scripts','quest_start_scripts','spell_scripts') and information_schema.TABLES.Table_schema='" + Properties.Settings.Default.DBMANGOS + "'";
                MySqlCommand comm = new MySqlCommand(sQuery, SQLConnection.conn);
                reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    if (!reader.HasRows)
                    {
                        MessageBox.Show("Your database doesn't contain the script tables. The application won't use the database anymore");
                        dbused = false;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            reader.Close();

            if (Datastores.dbused)
            {
                // Select all creature scripts and creature names
                MySqlCommand c = new MySqlCommand("SELECT * FROM " + sTable, SQLConnection.conn);
                reader = c.ExecuteReader();

                // clear existing script first
                db_scripts.scriptList.Clear();

                try
                {
                    while (reader.Read())
                    {
                        if (!db_scripts.scriptList.ContainsKey(reader.GetUInt32("id")))
                        {
                            db_script temp = new db_script(reader.GetUInt32("id"));
                            db_scripts.scriptList.Add(reader.GetUInt32("id"), temp);
                        }

                        Event_dataset_script item = new Event_dataset_script();

                        item.id = reader.GetUInt32("id");
                        item.delay = reader.GetUInt32("delay");
                        item.command = reader.GetInt32("command");
                        item.datalong = reader.GetUInt32("datalong");
                        item.datalong2 = reader.GetUInt32("datalong2");
                        item.buddy = reader.GetUInt32("buddy_entry");
                        item.radius = reader.GetUInt32("search_radius");
                        item.dataint = reader.GetUInt32("dataint");
                        item.dataint2 = reader.GetUInt32("dataint2");
                        item.dataint3 = reader.GetUInt32("dataint3");
                        item.dataint4 = reader.GetUInt32("dataint4");
                        item.position_x = reader.GetFloat("x");
                        item.position_y = reader.GetFloat("y");
                        item.position_z = reader.GetFloat("z");
                        item.orientation = reader.GetFloat("o");
                        item.comment = reader.GetString("comments");

                        db_scripts.scriptList[reader.GetUInt32("id")].line.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                reader.Close();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Length == 0)
            {
                MessageBox.Show("The id cannot be blank.");
                return;
            }

            string str = textBox1.Text.Trim();
            Int64 value;
            bool isNum = Int64.TryParse(str, out value);
            if (!isNum)
            {
                MessageBox.Show("The script id should be a number. Please enter a number.");
                return;
            }

            if (bIsCreature)
            {

                if (Datastores.dbused && !creatures.npcsAvailable.Contains(System.Convert.ToUInt32(textBox1.Text)))
                {
                    MessageBox.Show("This Creature is NOT in creature_template");
                    return;
                }

                creature newcreature = new creature(System.Convert.ToUInt32(textBox1.Text), "");
                if (!creatures.AddCreature(newcreature))
                    MessageBox.Show("ID already Exists!");
                else
                {
                    this.Hide();

                    (this.MdiParent as Hauptfenster).ShowNewForm(newcreature.creature_id);
                    (this.MdiParent as Hauptfenster).UpdateNPCListBox();
                }
            }
            else
            {
                db_script newscript = new db_script(System.Convert.ToUInt32(textBox1.Text));
                if (!db_scripts.AddScript(newscript))
                    MessageBox.Show("ID already Exists!");
                else
                {
                    this.Hide();

                    (this.MdiParent as Hauptfenster).ShowNewForm(newscript.id);
                    (this.MdiParent as Hauptfenster).UpdateNPCListBox();
                }
            }
        }
Example #8
0
        // Load DB scripts
        public static void LoadDBScripts(string sTable)
        {
            // Force using dots on floats, no matter which is the system setting
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            if (!Datastores.dbused)
                return;

            MySqlDataReader reader = null;

            // Check for the creatureAI tables
            try
            {
                string sQuery = "SELECT information_schema.TABLES.table_name FROM information_schema.TABLES " +
                    "where information_schema.TABLES.table_name IN ('dbscripts_on_creature_movement','dbscripts_on_event','dbscripts_on_go_use','dbscripts_on_go_template_use','dbscripts_on_gossip','dbscripts_on_quest_end','dbscripts_on_quest_start','dbscripts_on_spell') and information_schema.TABLES.Table_schema='" + Properties.Settings.Default.DBMANGOS + "'";
                MySqlCommand comm = new MySqlCommand(sQuery, SQLConnection.conn);
                reader = comm.ExecuteReader();

                while (reader.Read())
                {
                    if (!reader.HasRows)
                    {
                        MessageBox.Show("Your database doesn't contain the script tables. The application won't use the database anymore");
                        dbused = false;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            reader.Close();

            if (Datastores.dbused)
            {
                // Select all creature scripts and creature names
                MySqlCommand c = new MySqlCommand("SELECT * FROM " + sTable, SQLConnection.conn);
                reader = c.ExecuteReader();

                // clear existing script first
                db_scripts.scriptList.Clear();

                try
                {
                    while (reader.Read())
                    {
                        if (!db_scripts.scriptList.ContainsKey(reader.GetUInt32("id")))
                        {
                            db_script temp = new db_script(reader.GetUInt32("id"));
                            db_scripts.scriptList.Add(reader.GetUInt32("id"), temp);
                        }

                        Event_dataset_script item = new Event_dataset_script();

                        item.id = reader.GetUInt32("id");
                        item.delay = reader.GetUInt32("delay");
                        item.command = reader.GetInt32("command");
                        item.datalong = reader.GetUInt32("datalong");
                        item.datalong2 = reader.GetUInt32("datalong2");
                        item.buddy = reader.GetUInt32("buddy_entry");
                        item.radius = reader.GetUInt32("search_radius");
                        item.dataint = reader.GetUInt32("dataint");
                        item.dataint2 = reader.GetUInt32("dataint2");
                        item.dataint3 = reader.GetUInt32("dataint3");
                        item.dataint4 = reader.GetUInt32("dataint4");
                        item.position_x = reader.GetFloat("x");
                        item.position_y = reader.GetFloat("y");
                        item.position_z = reader.GetFloat("z");
                        item.orientation = reader.GetFloat("o");
                        item.comment = reader.GetString("comments");

                        db_scripts.scriptList[reader.GetUInt32("id")].line.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                reader.Close();
            }
        }
Example #9
0
        // Preview DB scripts
        public static string WriteScriptToWindow(db_script script, string table)
        {
            if (script == null)
                return "";

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("-- Script id: " + script.id);

            if (table == "quest_start_scripts" || table == "quest_end_scripts")
                sb.AppendLine(CreateScriptTemplateQuery(script, false, table));

            sb.AppendLine(SQLcreator.CreateDeleteQuery(script, table));
            sb.AppendLine(SQLcreator.CreateCreateQuery(script, table));

            return sb.ToString();
        }