public void Save(DGAdmin script) { try { XmlSerializer xmlSerializer = new XmlSerializer(typeof(SerializableDictionary <long, XLREntry>)); using (FileStream fs = new FileStream(ConfigValues.ConfigPath + FilePath, FileMode.Create)) { xmlSerializer.Serialize(fs, xlr_players); } } catch (Exception ex) { script.MainLog.WriteError(ex.Message); script.MainLog.WriteError(ex.StackTrace); WriteLog.Error(ex.Message); WriteLog.Error(ex.StackTrace); } }
public static string GetFormattedName(this Entity player, DGAdmin.GroupsDatabase database) { DGAdmin.GroupsDatabase.Group grp = player.GetGroup(database); var alias = ""; if (DGAdmin.ChatAlias.Keys.Contains(player.GUID)) { alias = DGAdmin.ChatAlias[player.GUID]; } if (!string.IsNullOrWhiteSpace(grp.short_name)) { return(DGAdmin.Lang_GetString("FormattedNameRank").Format(new Dictionary <string, string>() { { "<shortrank>", grp.short_name }, { "<rankname>", grp.group_name }, { "<name>", (alias != "")?alias : player.Name }, })); } return(DGAdmin.Lang_GetString("FormattedNameRankless").Format(new Dictionary <string, string>() { { "<name>", (alias != "")?alias : player.Name }, })); }
public PlayersFilter(DGAdmin script, Entity sender) { this.script = script; this.sender = sender; this.selectors = new List <Selector>(); }
/* ############## DYNAMIC_PROPERTIES ############### */ /* ############# basic implementation ############## */ public static void CFG_Dynprop_Init() { if (System.IO.Directory.Exists(@"admin\")) { WriteLog.Error("Failed loading dynamic_properties feature"); WriteLog.Error("\"admin/\" folder exsists! Delete it, and use \"players2/\" instead!"); return; } else { string DSR = @"players2/" + DGAdmin.UTILS_GetDSRName() + ".dsr"; List <string> DSRData = new List <string>(); if (System.IO.File.Exists(DSR)) { DSRData = System.IO.File.ReadAllLines(DSR).ToList(); } else { WriteLog.Error("Error loading dynamic_properties feature: DSR not exists! \"" + DSR + "\""); return; } // start of parsing int count = 0; Action _h_settings = () => { DSRData.ForEach((s) => { /* * //#DGAdmin settings <setting> = <value> */ Match match = (new Regex(@"^[\s]{0,31}\/\/#DGAdmin[\s]{1,31}settings[\s]{1,31}([a-z_]{0,63})[\s]{0,31}=[\s]{0,31}(.*)?$", RegexOptions.IgnoreCase)) .Match(s); if (match.Success) { string prop = match.Groups[1].Value.ToLower(); if (Settings.Keys.Contains(prop)) { count++; Settings[prop] = match.Groups[2].Value; } else { WriteLog.Warning("Unknown setting: " + prop); } } /* * //#DGAdmin cdvar <dvar name> = <value> */ match = (new Regex(@"^[\s]{0,31}\/\/#DGAdmin[\s]{1,31}cdvar[\s]{1,31}([a-z_]{0,63})[\s]{0,31}=[\s]{0,31}(.*)?$", RegexOptions.IgnoreCase)) .Match(s); if (match.Success) { count++; string prop = match.Groups[1].Value.ToLower(); string value = match.Groups[2].Value; DefaultCDvars.Add(prop, value); } /* * //#DGAdmin rules "Rule1\nRule2\nRule3" */ match = (new Regex(@"^[\s]{0,31}\/\/#DGAdmin[\s]{1,31}rules[\s]{1,31}'([^']*?)'[\s]{0,31}$".Replace('\'', '"'), RegexOptions.IgnoreCase)) .Match(s); if (match.Success) { count++; ConfigValues.cmd_rules = Regex.Split(match.Groups[1].Value, @"\\n").ToList(); } if (ConfigValues.settings_servertitle) { /* * //#DGAdmin servertitle map = <value> * //#DGAdmin servertitle mode = <value> */ match = (new Regex(@"^[\s]{0,31}\/\/#DGAdmin[\s]{1,31}servertitle[\s]{1,31}([a-z_]{0,63})[\s]{0,31}=[\s]{0,31}(.*)?$", RegexOptions.IgnoreCase)) .Match(s); switch (match.Groups[1].Value.ToLowerInvariant()) { case "map": ConfigValues.servertitle_map = match.Groups[2].Value; count++; break; case "mode": ConfigValues.servertitle_mode = match.Groups[2].Value; count++; break; } } }); }; /* * ############## ANTIWEAPONHACK ############### * get the list of restricted weapons */ Action _h_RestrictedWeapons = () => { DSRData.ForEach((s) => { Regex rgx = new Regex( @"^[\s]{0,31}gameOpt[\s]{1,31}commonOption\.weaponRestricted\.([a-z0-9_]{1,31})[\s]{1,31}'1'.*?$".Replace('\'', '"'), RegexOptions.IgnoreCase); Match match_weap = rgx.Match(s); if (match_weap.Success) { DGAdmin.RestrictedWeapons.Add(match_weap.Groups[1].Value); } }); }; _h_settings(); if (ConfigValues.ANTIWEAPONHACK) { _h_RestrictedWeapons(); } if (count > 0) { WriteLog.Info(string.Format("dynamic_properties:: Done reading {0} settings from \"{1}\"", count, DSR)); } } }