private void button3_Click(object sender, EventArgs e) { //addnpc Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox1.Text); if (!ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { npc.Kind = (Enums.NpcKind)byte.Parse(textBox2.Text); npc.X = ushort.Parse(textBox4.Text); npc.Y = ushort.Parse(textBox5.Text); npc.MapID = ushort.Parse(textBox6.Text); npc.Model = ushort.Parse(textBox7.Text); npc.Facing = (Enums.ConquerAngle)0; Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.INSERT); cmd.Insert("cq_npc").Insert("id", npc.UID).Insert("name", textBox3.Text).Insert("type", (ushort)npc.Kind).Insert("lookface", (int)npc.Model).Insert("cellx", npc.X).Insert("celly", npc.Y).Insert("mapid", npc.MapID); cmd.Execute(); npc.Model = (ushort)(npc.Model / 10); ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].AddNpc(npc); WriteLine("Successfully added new npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " already contains \n an npc with id " + npc.UID); } }
private void button1_Click(object sender, EventArgs e) { //removenpc Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox1.Text); if (ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.DELETE); cmd.Delete("cq_npc", "id", npc.UID); cmd.Execute(); ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.SafeRemove(npc.UID); WriteLine("Successfully removed npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " already doesn't contains \n an npc with id " + npc.UID); } }
private void button4_Click(object sender, EventArgs e) { Interfaces.INpc npc = new Network.GamePackets.NpcSpawn(); npc.UID = uint.Parse(textBox8.Text); if (ServerBase.Kernel.Maps[ushort.Parse(textBox6.Text)].Npcs.ContainsKey(npc.UID)) { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE); cmd.Update("cq_npc").Set("direction", textBox9.Text).Where("id", npc.UID); cmd.Execute(); ServerBase.Kernel.Maps[ushort.Parse(textBox8.Text)].Npcs[npc.UID].Facing = (Enums.ConquerAngle)ushort.Parse(textBox9.Text); WriteLine("Successfully updated npc " + npc.UID); } else { WriteLine("The map " + textBox6.Text + " doesn't contains \n an npc with id " + npc.UID); } }