public static void GetMembers() { foreach (KeyValuePair<uint, Game.Clans> G in Conquer_Online_Server.ServerBase.Kernel.ServerClans) { Game.Clans clan = G.Value; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("entities").Where("ClanID", clan.ClanId); MySqlReader r = new MySqlReader(cmd); while (r.Read()) { Game.ClanMembers member = new Conquer_Online_Server.Game.ClanMembers(); member.Donation = r.ReadUInt32("ClanDonation"); member.Rank = r.ReadByte("ClanRank"); member.UID = r.ReadUInt32("UID"); member.Name = r.ReadString("Name"); member.Class = r.ReadUInt16("Class"); member.Level = r.ReadByte("Level"); if (!clan.Members.ContainsKey(member.UID)) clan.Members.Add(member.UID, member); } r.Close(); } }
public static void Inscribe(Game.ConquerStructures.Society.ArsenalType Type, uint Donation, Interfaces.IConquerItem item, Game.Entity Entity) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("guild_arsenalsdonation").Insert("d_uid", Entity.UID).Insert("guild_uid", Entity.GuildID).Insert("name", Entity.Name).Insert("item_uid", item.UID).Insert("item_donation", Donation).Insert("item_arsenal_type", (byte)Type).Execute(); cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("items").Set("Inscribed", 1).Where("UID", item.UID).Execute(); }
public AccountTable(string username) { if (BannedIPs.Count == 0 && !LoadedIPs) { string[] lines = File.ReadAllLines(ServerBase.Constants.BannedPath); foreach (string line in lines) { if (line.Length >= 7) { BannedIPs.Add(line.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)[0]); } } LoadedIPs = true; } this.Username = username; this.Password = ""; this.IP = ""; this.LastCheck = DateTime.Now; this.State = AccountState.DoesntExist; this.EntityID = 0; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("accounts").Where("Username", username); MySqlReader r = new MySqlReader(cmd); if (r.Read()) { exists = true; this.Password = r.ReadString("Password"); this.IP = r.ReadString("IP"); this.EntityID = r.ReadUInt32("EntityID"); this.LastCheck = DateTime.FromBinary(r.ReadInt64("LastCheck")); this.State = (AccountState)r.ReadByte("State"); this.Email = r.ReadString("Email"); } r.Close(); }
public static void SaveProficiencies(Client.GameState client) { if (client.Entity == null) return; if (client.Proficiencies == null) return; if (client.Proficiencies.Count == 0) return; foreach (Interfaces.ISkill proficiency in client.Proficiencies.Values) { if(proficiency.Available) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("skills").Set("Level", proficiency.Level).Set("PreviousLevel", proficiency.PreviousLevel) .Set("Experience", proficiency.Experience).Where("EntityID", client.Entity.UID).And("ID", proficiency.ID).Execute(); } else { proficiency.Available = true; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("skills").Insert("Level", proficiency.Level).Insert("Experience", proficiency.Experience).Insert("EntityID", client.Entity.UID) .Insert("Type", "Proficiency").Insert("ID", proficiency.ID).Execute(); } } }
public static void CreateArsenal(ushort gID, Game.ConquerStructures.Society.ArsenalType Type) { if (!ContainsArsenal(gID)) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("guild_arsenals").Insert("guild_uid", gID).Execute(); } else { string val = ""; switch (Type) { case ArsenalType.Headgear: val = "head_allowed"; break; case ArsenalType.Armor: val = "armor_allowed"; break; case ArsenalType.Weapon: val = "weapon_allowed"; break; case ArsenalType.Ring: val = "ring_allowed"; break; case ArsenalType.Boots: val = "boots_allowed"; break; case ArsenalType.Necklace: val = "neck_allowed"; break; case ArsenalType.Fan: val = "fan_allowed"; break; case ArsenalType.Tower: val = "tower_allowed"; break; } if (val != "") { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("guild_arsenals").Set(val, 1).Execute(); } } }
public static void Delete(uint UID) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE); cmd.Delete("guild_arsenalsdonation", "item_uid", UID).Execute(); cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("items").Set("Inscribed", 0).Where("UID", UID).Execute(); }
public static void DeleteItem(uint UID) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE); int res = cmd.Delete("items", "UID", UID).Execute(); MySqlCommand cmds = new MySqlCommand(MySqlCommandType.DELETE).Delete("items", "UID", UID); cmds.Execute(); }
public static void KickClan(string name) { MySqlCommand cmd3 = new MySqlCommand(MySqlCommandType.UPDATE); cmd3.Update("entities").Set("ClanDonation", 0) .Set("ClanRank", 0) .Set("ClanID", 0).Where("Name", name).Execute(); }
public static void Update56(Conquer_Online_Server.Game.Entity Entity) { MySqlCommand Command = new MySqlCommand(MySqlCommandType.UPDATE); Command.Update("entities") .Set("My_Title", Entity.TitleActivated) .Where("UID", Entity.UID) .Execute(); }
public static void Update(Game.Entity Entity) { MySqlCommand Command = new MySqlCommand(MySqlCommandType.UPDATE); Command.Update("entities") .Set("StudyPoints", Entity.SubClasses.StudyPoints) .Where("UID", Entity.UID) .Execute(); }
public static void Disband(Game.ConquerStructures.Society.Guild guild) { MySqlCommand command = new MySqlCommand(MySqlCommandType.UPDATE); command.Update("entities").Set("GuildID", 0).Where("GuildID", guild.ID).Execute(); ServerBase.Kernel.Guilds.Remove(guild.ID); command = new MySqlCommand(MySqlCommandType.DELETE); command.Delete("guilds", "ID", guild.ID).Execute(); }
public static void Insert(Game.Entity Entity, byte id) { MySqlCommand Command = new MySqlCommand(MySqlCommandType.INSERT); Command.Insert("subclasses") .Insert("uid", id) .Insert("id", Entity.UID) .Execute(); }
public static void activateVip(Client.GameState client) { if (inPremium(client)) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("premium").Set("VipDays", client.VIPDays).Set("VipStartDate", DateTime.Now.Ticks).Where("Username", client.Account.Username).Execute(); } }
public static void GetAddingsForItem(Interfaces.IConquerItem item) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("itemadding").Where("UID", item.UID); MySqlReader r = new MySqlReader(cmd); while (r.Read()) { uint type = r.ReadUInt32("addingtype"); if (type == 0) { ItemAdding.Purification_ purification = new ItemAdding.Purification_(); purification.ItemUID = item.UID; purification.Available = true; purification.PurificationItemID = r.ReadUInt32("addingid"); purification.PurificationDuration = r.ReadUInt32("duration"); purification.PurificationLevel = r.ReadUInt32("addinglevel"); purification.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon")); if (purification.PurificationDuration != 0) { TimeSpan span1 = new TimeSpan(purification.AddedOn.AddSeconds(purification.PurificationDuration).Ticks); TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks); int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds); if (secondsleft <= 0) { purification.Available = false; RemoveAdding(item.UID, purification.PurificationItemID); continue; } } item.Purification = purification; } else { ItemAdding.Refinery_ extraeffect = new ItemAdding.Refinery_(); extraeffect.ItemUID = item.UID; extraeffect.Available = true; extraeffect.EffectID = r.ReadUInt32("addingid"); extraeffect.EffectLevel = r.ReadUInt32("addinglevel"); extraeffect.EffectPercent = r.ReadUInt32("addingpercent"); extraeffect.EffectDuration = r.ReadUInt32("duration"); extraeffect.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon")); if (extraeffect.EffectDuration != 0) { TimeSpan span1 = new TimeSpan(extraeffect.AddedOn.AddSeconds(extraeffect.EffectDuration).Ticks); TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks); int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds); if (secondsleft <= 0) { extraeffect.Available = false; RemoveAdding(item.UID, extraeffect.EffectID); continue; } } item.ExtraEffect = extraeffect; } } r.Close(); }
public static void AddFriend(Client.GameState client, Friend friend) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("friends").Insert("entityid", client.Entity.UID).Insert("friendid", friend.ID) .Insert("friendname", friend.Name).Execute(); cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("friends").Insert("entityid", friend.ID).Insert("friendid", client.Entity.UID) .Insert("friendname", client.Entity.Name).Execute(); }
public static void SaveHorseRaceStatistics(Network.GamePackets.HorseRaceStatistic stats, MySql.Data.MySqlClient.MySqlConnection conn) { var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("HorseRace") .Set("EntityName", stats.Name) .Set("Rank", stats.Rank) .Set("CurrentPts", stats.CurrentPts) .Where("EntityID", stats.EntityID); cmd.Execute(conn); }
public void AddRelation(UInt32 Relative, Network.GamePackets.ClanRelations.RelationTypes type) { MySqlCommand Command = new MySqlCommand(MySqlCommandType.INSERT); Command.Insert("clanrelation") .Insert("clanid", this.ClanId) .Insert("AssociatedId", Relative) .Insert("type", Convert.ToByte(type)) .Execute(); }
public static void AddPartner(Client.GameState client, TradePartner partner) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("partners").Insert("entityid", client.Entity.UID).Insert("partnerid", partner.ID) .Insert("partnername", partner.Name).Insert("probationstartedon", partner.ProbationStartedOn.Ticks).Execute(); cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("partners").Insert("entityid", partner.ID).Insert("partnerid", client.Entity.UID) .Insert("partnername", client.Entity.Name).Insert("probationstartedon", partner.ProbationStartedOn.Ticks).Execute(); }
public static void JoinClan(Client.GameState client) { MySqlCommand cmd3 = new MySqlCommand(MySqlCommandType.UPDATE); cmd3.Update("entities").Set("ClanID", client.Entity.Myclan.ClanId).Set("ClanRank", client.Entity.Myclan.Members[client.Entity.UID].Rank) .Set("ClanDonation", client.Entity.Myclan.Members[client.Entity.UID].Donation).Where("UID", client.Entity.UID).Execute(); Network.GamePackets.Clan cl = new Conquer_Online_Server.Network.GamePackets.Clan(client, 1); client.Send(cl.ToArray()); }
public static void DeleteAll(Dictionary<uint, Game.ConquerStructures.Society.ArsenalSingle> Items) { foreach (ArsenalSingle AS in Items.Values) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE); cmd.Delete("guild_arsenalsdonation", "item_uid", AS.UID).Execute(); cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("items").Set("Inscribed", 0).Where("UID", AS.UID).Execute(); } }
public static void Update(Game.Entity Entity, Game.SubClass SubClass) { MySqlCommand Command = new MySqlCommand(MySqlCommandType.UPDATE); Command.Update("subclasses") .Set("phase", SubClass.Phase) .Set("level", SubClass.Level) .Where("id", Entity.UID) .And("uid", SubClass.ID) .Execute(); }
public static void Create(Game.ConquerStructures.Society.Guild guild) { MySqlCommand command = new MySqlCommand(MySqlCommandType.INSERT); command.Insert("guilds"). Insert("ID", guild.ID). Insert("Name", guild.Name). Insert("SilverFund", 500000). Insert("LeaderName", guild.LeaderName); command.Execute(); }
public static void AddPurification(ItemAdding.Purification_ purification) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("itemadding") .Insert("uid", purification.ItemUID) .Insert("addingtype", 0) .Insert("addingid", purification.PurificationItemID) .Insert("addinglevel", purification.PurificationLevel) .Insert("duration", purification.PurificationDuration) .Insert("addedon", purification.AddedOn.Ticks).Execute(); }
public static void AddExtraEffect(ItemAdding.Refinery_ extraeffect) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("itemadding") .Insert("uid", extraeffect.ItemUID) .Insert("addingtype", 1) .Insert("addingid", extraeffect.EffectID) .Insert("addinglevel", extraeffect.EffectLevel) .Insert("addingpercent", extraeffect.EffectPercent) .Insert("duration", extraeffect.EffectDuration) .Insert("addedon", extraeffect.AddedOn.Ticks).Execute(); }
public static void getVipInfo(Client.GameState client) { MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT); cmd.Select("premium").Where("EntityName", client.Entity.Name); MySqlReader rdr = new MySqlReader(cmd); if (rdr.Read()) { client.VIPDate = DateTime.FromBinary(rdr.ReadInt64("VipStartDate")); client.VIPDays = rdr.ReadUInt32("VipDays"); rdr.Close(); } }
public static bool CreateEntity(Network.GamePackets.EnitityCreate eC, Client.GameState client, ref string message) { if (eC.Name.Length > 16) eC.Name = eC.Name.Substring(0, 16); if (eC.Name == "") return false; if (InvalidCharacters(eC.Name)) { message = "Invalid characters inside the name."; return false; } var rdr = new MySqlReader(new MySqlCommand(MySqlCommandType.SELECT).Select("entities").Where("name", eC.Name)); if (rdr.Read()) { rdr.Close(); message = "The chosen name is already in use."; return false; } rdr.Close(); client.Entity = new Game.Entity(Game.EntityFlag.Player, false); client.Entity.Name = eC.Name; DataHolder.GetStats(eC.Class, 1, client); client.Entity.UID = Program.EntityUID.Next; new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration").Set("EntityID", client.Entity.UID).Where("Server", ServerBase.Constants.ServerName).Execute(); client.CalculateStatBonus(); client.CalculateHPBonus(); client.Entity.Hitpoints = client.Entity.MaxHitpoints; client.Entity.Mana = (ushort)(client.Entity.Spirit * 5); client.Entity.Class = eC.Class; client.Entity.Body = eC.Body; if (eC.Body == 1003 || eC.Body == 1004) client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(1, 50); else client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(201, 250); byte Color = (byte)ServerBase.Kernel.Random.Next(4, 8); client.Entity.HairStyle = (ushort)(Color * 100 + 10 + (byte)ServerBase.Kernel.Random.Next(4, 9)); client.Account.EntityID = client.Entity.UID; client.Account.Save(); //723753 MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("entities").Insert("Name", eC.Name).Insert("Owner", client.Account.Username).Insert("Class", eC.Class).Insert("UID", client.Entity.UID) .Insert("Hitpoints", client.Entity.Hitpoints).Insert("Mana", client.Entity.Mana).Insert("Body", client.Entity.Body) .Insert("Face", client.Entity.Face).Insert("HairStyle", client.Entity.HairStyle).Insert("Strength", client.Entity.Strength) .Insert("Agility", client.Entity.Agility).Insert("Vitality", client.Entity.Vitality).Insert("Spirit", client.Entity.Spirit); cmd.Execute(); message = "ANSWER_OK"; return true; }
public static void DeleteTabelTop2(Client.GameState C) { MySqlCommand cmds = new MySqlCommand(MySqlCommandType.DELETE) .Delete("Top2", "TopTrojan2", C.Entity.TopTrojan2) .Delete("Top2", "TopWarrior2", C.Entity.TopWarrior2) .Delete("Top2", "TopMonk2", C.Entity.TopMonk2) .Delete("Top2", "TopNinja2", C.Entity.TopNinja2) .Delete("Top2", "TopWaterTaoist2", C.Entity.TopWaterTaoist2) .Delete("Top2", "TopArcher2", C.Entity.TopArcher2) .Delete("Top2", "TopFireTaoist2", C.Entity.TopFireTaoist2) .Delete("Top2", "UID", C.Entity.UID); cmds.Execute(); }
public static void DeleteTabelTop22(Client.GameState C) { MySqlCommand cmdd = new MySqlCommand(MySqlCommandType.UPDATE); int ress = cmdd.Update("Top2") .Set("UID", 0) .Set("TopTrojan2", 0) .Set("TopWarrior2", 0) .Set("TopMonk2", 0) .Set("TopNinja2", 0) .Set("TopWaterTaoist2", 0) .Set("TopArcher2", 0) .Set("TopFireTaoist2", 0) .Where("UID", C.Entity.UID).Execute(); }
public static void ProcessTransaction(Client.GameState owner, Client.GameState receiver, uint amount, TransactionLogAction action) { DateTime Date = DateTime.Now; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("transactionlog"). Insert("owneruid", owner.Entity.UID). Insert("receiveruid", receiver.Entity.UID). Insert("amount", amount). Insert("ownerhadamount", owner.Entity.ConquerPoints). Insert("receiverhadamount", receiver.Entity.ConquerPoints). Insert("type", (byte)action). Insert("date", Date.ToString()). Execute(); }
public static void Lotto(Client.GameState client, bool New) { if (New) { client.LotteryEntries = 1; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT); cmd.Insert("quest").Insert("EntityName", client.Entity.Name).Insert("IP", client.IP).Insert("LottoDate", DateTime.Now.Ticks).Insert("LottoTries", 1).Insert("Username", client.Account.Username).Execute(); } else { client.LotteryEntries += 1; MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE); cmd.Update("quest").Set("LottoDate", DateTime.Now.Ticks).Set("LottoTries", client.LotteryEntries).Set("Username", client.Account.Username).Where("EntityName", client.Entity.Name).Or("IP", client.IP).Execute(); } }