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); }
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); }
public bool ItemIsBanned(string name, TPPlayer ply) { if (ItemBans.Contains(new ItemBan(name))) { ItemBan b = GetItemBanByName(name); return(!b.HasPermissionToUseItem(ply)); } return(false); }
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); } } }