Пример #1
0
        public bool AllowGroup(int id, string name)
        {
            bool    flag;
            string  str         = "";
            BuffBan buffBanById = Koishi.BanBuff.Utils.GetBuffBanById(id);

            if (buffBanById != null)
            {
                try
                {
                    str = string.Join(",", buffBanById.AllowedGroups);
                    if (str.Length > 0)
                    {
                        str = string.Concat(str, ",");
                    }
                    str = string.Concat(str, name);
                    buffBanById.SetAllowedGroups(str);
                    IDbConnection dbConnection = this.database;
                    object[]      objArray     = new object[] { str, id };
                    flag = DbExt.Query(dbConnection, "UPDATE BuffBans SET AllowedGroups=@0 WHERE BuffID=@1", objArray) > 0;
                }
                catch (Exception exception)
                {
                    TShock.Log.Error(exception.ToString());
                    return(false);
                }
                return(flag);
            }
            return(false);
        }
Пример #2
0
 public void UpdateBuffBans()
 {
     this.BuffBans.Clear();
     using (QueryResult queryResult = DbExt.QueryReader(this.database, "SELECT * FROM BuffBans", new object[0]))
     {
         while (queryResult != null && queryResult.Read())
         {
             BuffBan buffBan = new BuffBan(queryResult.Get <int>("BuffID"));
             buffBan.SetAllowedGroups(queryResult.Get <string>("AllowedGroups"));
             this.BuffBans.Add(buffBan);
         }
     }
 }