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); } }
public void Update(uint value, string Colum) { if (Loaded) { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE); cmd.Update("entities").Set("Blessing_Exp", value).Where("UID", Owner).Execute(); } }
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); } }
/// <summary> /// Convert C# datetime type and data to mysql for V0.9.9.7 /// </summary> void CDfcts() { var ncmd = new Database.MySqlCommand(MySqlCommandType.SELECT).Select("logs"); MySqlReader r = new MySqlReader(ncmd); while (r.Read()) { var uN = r.ReadString("Username"); var uLi = r.ReadString("LoginDate"); var uLo = r.ReadString("LogoutDate"); var oUli = uLi; var dt1 = Convert.ToDateTime(uLi); uLi = dt1.ToString("yyyy-MM-dd HH:mm:ss"); var ucmd = new Database.MySqlCommand(MySqlCommandType.UPDATE); if (uLo != "") { var dt2 = Convert.ToDateTime(uLo); uLo = dt2.ToString("yyyy-MM-dd HH:mm:ss"); ucmd.Update("logs") .Set("LoginDate", uLi) .Set("LogoutDate", uLo) .Where("Username", uN) .And("LoginDate", oUli) .Execute(); } else { ucmd.Update("logs") .Set("LoginDate", uLi) .Where("Username", uN) .And("LoginDate", oUli) .Execute(); } } r.Close(); }
public bool ExecutClient(uint uid) { bool right = false; var cmd = new Database.MySqlCommand(Database.MySqlCommandType.SELECT); cmd.Select("accounts").Where("EntityID", uid); var r = new Database.MySqlReader(cmd); if (r.Read()) { this.Account = new Conquer_Online_Server.Database.AccountTable(r.ReadString("Username")); right = true; } r.Close(); return right; }
public bool TryJoin(UInt32 password, UInt32 _uid) { bool right = false; var cmd = new Database.MySqlCommand(Database.MySqlCommandType.SELECT); cmd.Select("accounts").Where("EntityID", _uid); var r = new Database.MySqlReader(cmd); if (r.Read()) if (password == (uint)r.ReadString("Password").GetHashCode()) right = true; r.Close(); if (right) { if (_uid != 0) right = ExecutClient(_uid); } return right; }
public Boolean TestEntity(UInt32 _uid) { string names = ""; var cmd = new Database.MySqlCommand(Database.MySqlCommandType.SELECT); cmd.Select("entities").Where("UID", _uid); var r = new Database.MySqlReader(cmd); if (r.Read()) names = r.ReadString("Name"); r.Close(); if (names == "") return false;//"NEW_ROLE"; else return true;//"ANSWER_OK"; }
public void SaveTimeVot() { Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.UPDATE); cmd.Update("entities").Set("TimerVot", TimerVot.Ticks).Where("UID", this.UID).Execute(); }
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); } }
public FlowerRank(uint UID) { int PacketLength = 80; uint charamount = 0; uint place = 1; string[] playernames = new string[100000]; uint[] playerflowers = new uint[1000000]; MemoryStream Stream = new MemoryStream(); BinaryWriter Writer = new BinaryWriter(Stream); Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.SELECT); cmd.Select("flowers").Order("redroses DESC"); PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd); while (r.Read()) { int redroses = r.ReadInt32("redroses"); if (redroses != 0) { uint charuid = r.ReadUInt32("id"); PacketLength += (r.ReadString("name").Length * 2) + 36; playernames[charamount] = r.ReadString("name"); playerflowers[charamount] = r.ReadUInt32("redroses"); charamount++; } } Buffer = new byte[80 +8]; WriteUInt16(80, 0, Buffer); WriteUInt16(1151, 2, Buffer); WriteUInt32(1, 4, Buffer); WriteUInt32(UID, 8, Buffer); WriteUInt32(0, 12, Buffer); WriteUInt32(charamount, 16, Buffer); int position = 24; for(int x = 0; x < charamount; x++) { // WriteUInt32(1, position, Buffer); // position+=4; WriteUInt32(place, position, Buffer); place++; //WriteUInt32(place, position, Buffer); position+=4; WriteUInt32(playerflowers[1], position, Buffer); position += 4; WriteUInt32(playerflowers[1], position, Buffer); position += 4; WriteUInt32(UID, position, Buffer); position += 4; WriteUInt32(UID, position, Buffer); position += 4; WriteString(playernames[x], position, Buffer); position += 16; WriteUInt32(1, position, Buffer); position += 4; WriteString(playernames[x], position, Buffer); position += 8; position = position + 16; } WriteString("TQServer", position, Buffer); }