public static Enums.AccountStatus Authenticate(Client.AuthClient client, string Account, string Password)
        {
            try
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("AuthConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.SELECT, true))
                    {
                        cmd.AddWhereValue("AccountName", Account);
                        cmd.AddWhereValue("AccountPassword", Password);

                        cmd.Finish("DB_Accounts");
                    }

                    if (!sql.Read())
                        return Enums.AccountStatus.Invalid_AccountID_Or_Password;
                    client.DatabaseUID = sql.ReadInt32("AccountID");
                    client.Server = sql.ReadByte("AccountServer");
                    client.Account = Account;
                    client.Password = Password;
                    using (var sql2 = new SqlHandler(Program.Config.ReadString("AuthConnectionString")))
                    {
                        using (var cmd2 = new SqlCommandBuilder(sql2, SqlCommandType.UPDATE, true))
                        {
                            cmd2.AddWhereValue("AccountID", client.DatabaseUID);
                            if (sql.ReadBoolean("AccountBanned"))
                            {
                                DateTime banexpire = sql.ReadDateTime("AccountBanExpire");
                                if (DateTime.Now < banexpire)
                                    return Enums.AccountStatus.Account_Banned;

                                cmd2.AddUpdateValue("AccountBanned", false);
                            }

                            cmd2.AddUpdateValue("AccountLastLoginIP", client.NetworkClient.IP);
                            cmd2.Finish("DB_Accounts");
                        }
                        sql2.Execute();
                    }
                }
                return Enums.AccountStatus.Ready;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return Enums.AccountStatus.Datebase_Error;
            }
        }
        public static void AddSpouse(Entities.GameClient client1, Entities.GameClient client2)
        {
            client1.SpouseDatabaseUID = client2.DatabaseUID;
            client2.SpouseDatabaseUID = client1.DatabaseUID;

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                {
                    cmd.AddWhereValue("PlayerID", client1.DatabaseUID);
                    cmd.AddUpdateValue("PlayerSpouseID", client2.DatabaseUID);
                    cmd.Finish("DB_Players");
                }
                sql.Execute();
                sql.Forward(Program.Config.ReadString("GameConnectionString"), "");
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                {
                    cmd.AddWhereValue("PlayerID", client2.DatabaseUID);
                    cmd.AddUpdateValue("PlayerSpouseID", client1.DatabaseUID);
                    cmd.Finish("DB_Players");
                }
                sql.Execute();
            }
        }
 public static void UpdateNobilityDonation(int Identifier, string Column, object Value)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", Identifier);
             cmd.AddUpdateValue(Column, Value);
             cmd.Finish("DB_NobilityBoard");
         }
         sql.Execute();
     }
 }
 public static void SaveArenaInfo(Data.ArenaInfo arena)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", arena.DatabaseID);
             cmd.AddUpdateValue("PlayerName", arena.Name);
             cmd.AddUpdateValue("ArenaLevel", arena.Level);
             cmd.AddUpdateValue("ArenaClass", arena.Class);
             cmd.AddUpdateValue("Mesh", arena.Mesh);
             cmd.AddUpdateValue("HonorPoints", arena.DatabaseID);
             cmd.AddUpdateValue("ArenaPoints", arena.ArenaPoints);
             cmd.AddUpdateValue("TotalWins", arena.ArenaTotalWins);
             cmd.AddUpdateValue("TotalWinsToday", arena.ArenaWinsToday);
             cmd.AddUpdateValue("TotalLoss", arena.ArenaTotalLoss);
             cmd.AddUpdateValue("TotalLossToday", arena.ArenaLossToday);
             cmd.Finish("DB_ArenaQualifier");
         }
         sql.Execute();
     }
 }
        public static void UpdateAuthentication(Client.AuthClient client)
        {
            if (PlayerExists(client.DatabaseUID))
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddUpdateValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddUpdateValue("PlayerLoginOK", true);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
            else
            {
                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("PlayerNew", true);
                        cmd.AddInsertValue("PlayerAccount", client.Account);
                        cmd.AddInsertValue("PlayerLastEntityUID", client.EntityUID);
                        cmd.AddInsertValue("PlayerLoginOK", true);
                        cmd.AddInsertValue("PlayerServer", client.Server);

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
        }
        // -1 = finished
        public static void SaveQuest(Entities.GameClient client, string Name, int Progress, string InfoString)
        {
            bool Exists = false;
            using (var existsql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var existcmd = new SqlCommandBuilder(existsql, SqlCommandType.SELECT, true))
                {
                    existcmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    existcmd.AddWhereValue("QuestName", Name);
                    existcmd.Finish("DB_Quests");
                }
                Exists = existsql.Read();
            }

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                if (Exists)
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddWhereValue("QuestName", Name);
                        cmd.AddUpdateValue("QuestProgress", Progress.ToString());
                        cmd.AddUpdateValue("QuestInfo", InfoString);
                        cmd.Finish("DB_Quests");
                    }
                }
                else
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("QuestName", Name);
                        cmd.AddInsertValue("QuestProgress", Progress.ToString());
                        cmd.AddInsertValue("QuestInfo", InfoString);
                        cmd.Finish("DB_Quests");
                    }
                }
                sql.Execute();
            }
        }
        /// <summary>
        /// Saves profs.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="prof">The prof.</param>
        public static void SaveProf(Entities.GameClient client, Data.SpellInfo prof)
        {
            if (!client.LoggedIn || client.IsAIBot)
                return;
            bool Exists = false;
            using (var existsql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var existcmd = new SqlCommandBuilder(existsql, SqlCommandType.SELECT, true))
                {
                    existcmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    existcmd.AddWhereValue("Prof", prof.ID);
                    existcmd.Finish("DB_PlayerProfs");
                }
                Exists = existsql.Read();
            }

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                if (Exists)
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddWhereValue("Prof", prof.ID);
                        cmd.AddUpdateValue("ProfLevel", prof.Level);
                        cmd.AddUpdateValue("ProfExperience", prof.Experience);
                        cmd.Finish("DB_PlayerProfs");
                    }
                }
                else
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.INSERT, false))
                    {
                        cmd.AddInsertValue("PlayerID", client.DatabaseUID);
                        cmd.AddInsertValue("Prof", prof.ID);
                        cmd.AddInsertValue("ProfLevel", prof.Level);
                        cmd.AddInsertValue("ProfExperience", prof.Experience);
                        cmd.Finish("DB_PlayerProfs");
                    }
                }

                sql.Execute();
            }
        }
 public static void SaveGuildRank(int UID, Enums.GuildRank rank)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", UID);
             cmd.AddUpdateValue("PlayerGuildRank", rank.ToString());
             cmd.Finish("DB_Players");
         }
         sql.Execute();
     }
 }
        /// <summary>
        /// Saves the basic information of a client.
        /// </summary>
        /// <param name="client">The client.</param>
        public static void Save(Entities.GameClient client)
        {
            try
            {
                if (!client.LoggedIn || client.IsAIBot)
                    return;

                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddUpdateValue("PlayerMapID", client.Map.MapID);
                        cmd.AddUpdateValue("PlayerLastMapID", client.LastMapID);
                        cmd.AddUpdateValue("PlayerX", client.X);
                        cmd.AddUpdateValue("PlayerY", client.Y);
                        cmd.AddUpdateValue("PlayerSpouseID", client.SpouseDatabaseUID);
                        cmd.AddUpdateValue("TournyKills", client.TournamentInfo.TotalKills);
                        cmd.AddUpdateValue("TournyDeaths", client.TournamentInfo.TotalDeaths);
                        if (client.Guild == null)
                        {
                            cmd.AddUpdateValue("PlayerGuildRank", "None");
                            cmd.AddUpdateValue("PlayerGuild", "");
                            cmd.AddUpdateValue("PlayerGuildDonation", (uint)0);
                            cmd.AddUpdateValue("PlayerGuildCPDonation", (uint)0);
                        }
                        else
                        {
                            cmd.AddUpdateValue("PlayerGuildRank", client.GuildMemberInfo.Rank.ToString());
                            cmd.AddUpdateValue("PlayerGuild", client.Guild.Name);
                            cmd.AddUpdateValue("PlayerGuildDonation", client.GuildMemberInfo.MoneyDonation);
                            cmd.AddUpdateValue("PlayerGuildCPDonation", client.GuildMemberInfo.CPDonation);
                        }
                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to save {0}.", client.Name);
                Console.WriteLine(e.ToString());
            }
        }
 public static void RemoveGuild(int UID, bool MakeMember = false)
 {
     using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
     {
         using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
         {
             cmd.AddWhereValue("PlayerID", UID);
             if (!MakeMember)
             {
                 cmd.AddUpdateValue("PlayerGuildRank", "None");
                 cmd.AddUpdateValue("PlayerGuild", "");
                 cmd.AddUpdateValue("PlayerGuildDonation", (uint)0);
                 cmd.AddUpdateValue("PlayerGuildCPDonation", (uint)0);
             }
             else
             {
                 cmd.AddUpdateValue("PlayerGuildRank", "Member");
             }
             cmd.Finish("DB_Players");
         }
         sql.Execute();
     }
 }
        public static void UpdateCharacter(Entities.GameClient client, string Column, object Value)
        {
            if (client.IsAIBot)
                return;

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                {
                    cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    cmd.AddUpdateValue(Column, Value);
                    cmd.Finish("DB_Players");
                }
                sql.Execute();
            }
        }
        /// <summary>
        /// Creates a new character.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="name">The character name.</param>
        /// <param name="job">The job id.</param>
        /// <param name="model">The model.</param>
        /// <returns>Returns true if the character was created successfully.</returns>
        public static bool CreateCharacter(Entities.GameClient client, string name, byte job, ushort model)
        {
            try
            {
                client.Name = name;
                client.BaseEntity.SetBaseStats();
                client.BaseEntity.CalculateBaseStats();

                using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
                {
                    using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                    {
                        cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                        cmd.AddUpdateValue("PlayerName", name);//1010 61 109
                        cmd.AddUpdateValue("PlayerMapID", (ushort)1010);
                        cmd.AddUpdateValue("PlayerLastMapID", (ushort)1010);
                        cmd.AddUpdateValue("PlayerX", (ushort)61);
                        cmd.AddUpdateValue("PlayerY", (ushort)109);
                        cmd.AddUpdateValue("PlayerMoney", (uint)1020);
                        cmd.AddUpdateValue("PlayerCPs", (uint)0);
                        cmd.AddUpdateValue("PlayerBoundCPs", (uint)0);
                        cmd.AddUpdateValue("PlayerLevel", (byte)1);
                        cmd.AddUpdateValue("PlayerExperience", (ulong)0);
                        cmd.AddUpdateValue("PlayerAvatar", (ushort)AvatarDatabase.GenerateAvatar(model >= 2000));
                        cmd.AddUpdateValue("PlayerHairStyle", (ushort)410);
                        cmd.AddUpdateValue("PlayerModel", (ushort)model);
                        cmd.AddUpdateValue("PlayerClass", ((Enums.Class)job).ToString());
                        cmd.AddUpdateValue("PlayerQuizPoints", (uint)0);
                        cmd.AddUpdateValue("PlayerPKPoints", (short)0);
                        cmd.AddUpdateValue("PlayerMaxHP", (int)client.MaxHP);
                        cmd.AddUpdateValue("PlayerMaxMP", (int)client.MaxMP);
                        cmd.AddUpdateValue("PlayerHP", (int)client.MaxHP);
                        cmd.AddUpdateValue("PlayerMP", (int)client.MaxMP);
                        cmd.AddUpdateValue("PlayerStrength", (ushort)client.Strength);
                        cmd.AddUpdateValue("PlayerAgility", (ushort)client.Agility);
                        cmd.AddUpdateValue("PlayerVitality", (ushort)client.Vitality);
                        cmd.AddUpdateValue("PlayerSpirit", (ushort)client.Spirit);
                        cmd.AddUpdateValue("PlayerAttributePoints", (ushort)0);
                        cmd.AddUpdateValue("PlayerStamina", (byte)0);
                        cmd.AddUpdateValue("PlayerReborns", (byte)0);
                        cmd.AddUpdateValue("PlayerSpouseID", (int)0);
                        cmd.AddUpdateValue("PlayerTitle", Enums.PlayerTitle.None.ToString());
                        cmd.AddUpdateValue("PlayerStatusFlag", (ulong)0);
                        cmd.AddUpdateValue("PlayerNew", false);
                        cmd.AddUpdateValue("PlayerGuildRank", Enums.GuildRank.None.ToString());
                        cmd.AddUpdateValue("PlayerGuild", "");
                        cmd.AddUpdateValue("PlayerGuildDonation", (uint)0);
                        cmd.AddUpdateValue("PlayerWarehouseMoney", (uint)0);
                        cmd.AddUpdateValue("TournyDeaths", (uint)0);
                        cmd.AddUpdateValue("TournyKills", (uint)0);
                        cmd.AddUpdateValue("TournyDeaths", (uint)0);
                        cmd.AddUpdateValue("PlayerQuestPoints", (uint)0);
                        cmd.AddUpdateValue("PlayerPermission", "Normal");
                        cmd.AddUpdateValue("PlayerFaction", "None");

                        cmd.Finish("DB_Players");
                    }
                    sql.Execute();
                }
                switch ((Enums.Class)job)
                {
                    case Enums.Class.InternTrojan:
                    case Enums.Class.InternWarrior:
                    case Enums.Class.InternNinja:
                        {
                            IniFile itemfile = client.CharDB.ItemFiles[0];
                            #region Weapon
                            itemfile.SetSection("0");
                            itemfile.Write<uint>("ItemID", 410301);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Coat
                            itemfile.SetSection("1");
                            itemfile.Write<uint>("ItemID", 132005);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Potions
                            for (int i = 2; i <= 6; i++)
                            {
                                itemfile.SetSection(i.ToString());
                                itemfile.Write<uint>("ItemID", 1000000);
                                itemfile.Write<byte>("Plus", 0);
                                itemfile.Write<byte>("Bless", 0);
                                itemfile.Write<byte>("Enchant", 0);
                                itemfile.WriteString("Gem1", "NoSocket");
                                itemfile.WriteString("Gem2", "NoSocket");
                                itemfile.Write<short>("CurrentDura", 100);
                                itemfile.Write<short>("MaxDura", 100);
                                itemfile.WriteString("Color", "Orange");
                                itemfile.Write<uint>("SocketProgress", 0);
                            }
                            #endregion
                            break;
                        }
                    case Enums.Class.InternArcher:
                        {
                            IniFile itemfile = client.CharDB.ItemFiles[0];
                            #region Weapon
                            itemfile.SetSection("0");
                            itemfile.Write<uint>("ItemID", 500301);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Coat
                            itemfile.SetSection("1");
                            itemfile.Write<uint>("ItemID", 132005);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Potions
                            for (int i = 2; i <= 6; i++)
                            {
                                itemfile.SetSection(i.ToString());
                                itemfile.Write<uint>("ItemID", 1000000);
                                itemfile.Write<byte>("Plus", 0);
                                itemfile.Write<byte>("Bless", 0);
                                itemfile.Write<byte>("Enchant", 0);
                                itemfile.WriteString("Gem1", "NoSocket");
                                itemfile.WriteString("Gem2", "NoSocket");
                                itemfile.Write<short>("CurrentDura", 100);
                                itemfile.Write<short>("MaxDura", 100);
                                itemfile.WriteString("Color", "Orange");
                                itemfile.Write<uint>("SocketProgress", 0);
                            }
                            #endregion
                            break;
                        }
                    case Enums.Class.InternTaoist:
                        {
                            IniFile itemfile = client.CharDB.ItemFiles[0];
                            #region Weapon
                            itemfile.SetSection("0");
                            itemfile.Write<uint>("ItemID", 421301);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Coat
                            itemfile.SetSection("1");
                            itemfile.Write<uint>("ItemID", 132005);
                            itemfile.Write<byte>("Plus", 0);
                            itemfile.Write<byte>("Bless", 0);
                            itemfile.Write<byte>("Enchant", 0);
                            itemfile.WriteString("Gem1", "NoSocket");
                            itemfile.WriteString("Gem2", "NoSocket");
                            itemfile.Write<short>("CurrentDura", 100);
                            itemfile.Write<short>("MaxDura", 100);
                            itemfile.WriteString("Color", "Orange");
                            itemfile.Write<uint>("SocketProgress", 0);
                            #endregion
                            #region Potions
                            for (int i = 2; i <= 3; i++)
                            {
                                itemfile.SetSection(i.ToString());
                                itemfile.Write<uint>("ItemID", 1001000);
                                itemfile.Write<byte>("Plus", 0);
                                itemfile.Write<byte>("Bless", 0);
                                itemfile.Write<byte>("Enchant", 0);
                                itemfile.WriteString("Gem1", "NoSocket");
                                itemfile.WriteString("Gem2", "NoSocket");
                                itemfile.Write<short>("CurrentDura", 100);
                                itemfile.Write<short>("MaxDura", 100);
                                itemfile.WriteString("Color", "Orange");
                                itemfile.Write<uint>("SocketProgress", 0);
                            }
                            for (int i = 4; i <= 6; i++)
                            {
                                itemfile.SetSection(i.ToString());
                                itemfile.Write<uint>("ItemID", 1000000);
                                itemfile.Write<byte>("Plus", 0);
                                itemfile.Write<byte>("Bless", 0);
                                itemfile.Write<byte>("Enchant", 0);
                                itemfile.WriteString("Gem1", "NoSocket");
                                itemfile.WriteString("Gem2", "NoSocket");
                                itemfile.Write<short>("CurrentDura", 100);
                                itemfile.Write<short>("MaxDura", 100);
                                itemfile.WriteString("Color", "Orange");
                                itemfile.Write<uint>("SocketProgress", 0);
                            }
                            #endregion
                            break;
                        }
                }
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }
        }
        public static void SaveTourny(Entities.GameClient client)
        {
            if (!client.LoggedIn || client.IsAIBot)
                return;

            using (var sql = new SqlHandler(Program.Config.ReadString("GameConnectionString")))
            {
                using (var cmd = new SqlCommandBuilder(sql, SqlCommandType.UPDATE, true))
                {
                    cmd.AddWhereValue("PlayerID", client.DatabaseUID);
                    cmd.AddUpdateValue("TournyKills", client.TournamentInfo.TotalKills);
                    cmd.AddUpdateValue("TournyDeaths", client.TournamentInfo.TotalDeaths);

                    cmd.Finish("DB_Players");
                }
                sql.Execute();
            }
        }