Beispiel #1
0
        public bool AllowGroup(string item, string name)
        {
            string  groupsNew = "";
            ItemBan b         = GetItemBanByName(item);

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

                    int q = database.Query("UPDATE ItemBans SET AllowedGroups=@0 WHERE ItemName=@1", groupsNew,
                                           item);

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

            return(false);
        }
Beispiel #2
0
        public bool RemoveGroup(string item, string group)
        {
            ItemBan b = GetItemBanByName(item);

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

                    if (q > 0)
                    {
                        return(true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.ToString());
                }
            }
            return(false);
        }
Beispiel #3
0
 public bool ItemIsBanned(string name, TPPlayer ply)
 {
     if (ItemBans.Contains(new ItemBan(name)))
     {
         ItemBan b = GetItemBanByName(name);
         return(!b.HasPermissionToUseItem(ply));
     }
     return(false);
 }
Beispiel #4
0
        public void UpdateItemBans()
        {
            ItemBans.Clear();

            using (var reader = database.QueryReader("SELECT * FROM ItemBans"))
            {
                while (reader != null && reader.Read())
                {
                    ItemBan ban = new ItemBan(reader.Get <string>("ItemName"));
                    ban.SetAllowedGroups(reader.Get <string>("AllowedGroups"));
                    ItemBans.Add(ban);
                }
            }
        }