Example #1
0
        public bool AllowGroup(short id, string name)
        {
            string        groupsNew = "";
            ProjectileBan b         = GetBanById(id);

            if (b != null)
            {
                try
                {
                    groupsNew = String.Join(",", b.AllowedGroups);
                    if (groupsNew.Length > 0)
                    {
                        groupsNew += ",";
                    }
                    groupsNew += name;
                    b.SetAllowedGroups(groupsNew);

                    int q = database.Query("UPDATE ProjectileBans SET AllowedGroups=@0 WHERE ProjectileId=@1", groupsNew,
                                           id);

                    return(q > 0);
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }

            return(false);
        }
Example #2
0
        public bool RemoveGroup(short id, string group)
        {
            ProjectileBan b = GetBanById(id);

            if (b != null)
            {
                try
                {
                    b.RemoveGroup(group);
                    string groups = string.Join(",", b.AllowedGroups);
                    int    q      = database.Query("UPDATE ProjectileBans SET AllowedGroups=@0 WHERE ProjectileId=@1", groups,
                                                   id);

                    if (q > 0)
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    TShock.Log.Error(ex.ToString());
                }
            }
            return(false);
        }
Example #3
0
 public bool ProjectileIsBanned(short id, TSPlayer ply)
 {
     if (ProjectileBans.Contains(new ProjectileBan(id)))
     {
         ProjectileBan b = GetBanById(id);
         return(!b.HasPermissionToCreateProjectile(ply));
     }
     return(false);
 }
Example #4
0
        public void UpdateBans()
        {
            ProjectileBans.Clear();

            using (var reader = database.QueryReader("SELECT * FROM ProjectileBans"))
            {
                while (reader != null && reader.Read())
                {
                    ProjectileBan ban = new ProjectileBan((short)reader.Get <Int32>("ProjectileID"));
                    ban.SetAllowedGroups(reader.Get <string>("AllowedGroups"));
                    ProjectileBans.Add(ban);
                }
            }
        }