public static bool Load(Player p) { if (!File.Exists("players/" + p.name + "DB.txt")) { return(false); } foreach (string line in File.ReadAllLines("players/" + p.name + "DB.txt")) { if (string.IsNullOrEmpty(line) || line[0] == '#') { continue; } string[] parts = line.Split(trimChars, 2); if (parts.Length < 2) { continue; } string key = parts[0].Trim(), value = parts[1].Trim(); if (key.CaselessEq("nick")) { p.DisplayName = value; } } p.SetPrefix(); return(true); }
public static bool Load( Player p ) { if ( File.Exists( "players/" + p.name + "DB.txt" ) ) { foreach ( string line in File.ReadAllLines( "players/" + p.name + "DB.txt" ) ) { if ( !string.IsNullOrEmpty( line ) && !line.StartsWith( "#" ) ) { string key = line.Split( '=' )[0].Trim(); string value = line.Split( '=' )[1].Trim(); string section = "nowhere yet..."; try { switch ( key.ToLower() ) { case "nick": p.DisplayName = value; section = key; break; } } catch(Exception e) { Server.s.Log( "Loading " + p.name + "'s EXP database failed at section: " + section ); Server.ErrorLog( e ); } p.timeLogged = DateTime.Now; } } p.SetPrefix(); return true; } else { Save( p ); return false; } }
/// <summary> Attempts to change the title of the target player </summary> /// <remarks> Not allowed when players who cannot speak (e.g. muted) </remarks> public static bool SetTitle(Player p, string target, string title) { if (title.Length >= 20) { p.Message("&WTitle must be under 20 characters."); return(false); } Player who = PlayerInfo.FindExact(target); if (title.Length == 0) { MessageAction(p, target, who, "λACTOR &Sremoved λTARGET title"); } else { if (!p.CheckCanSpeak("change titles")) { return(false); } MessageAction(p, target, who, "λACTOR &Schanged λTARGET title to &b[" + title + "&b]"); } if (who != null) { who.title = title; } if (who != null) { who.SetPrefix(); } PlayerDB.Update(target, PlayerData.ColumnTitle, title.UnicodeToCp437()); return(true); }
/// <summary> Attempts to change the title color of the target player </summary> public static bool SetTitleColor(Player p, string target, string name) { string color = ""; Player who = PlayerInfo.FindExact(target); if (name.Length == 0) { MessageAction(p, target, who, "λACTOR &Sremoved λTARGET title color"); } else { color = Matcher.FindColor(p, name); if (color == null) { return(false); } MessageAction(p, target, who, "λACTOR &Schanged λTARGET title color to " + color + Colors.Name(color)); } if (who != null) { who.titlecolor = color; } if (who != null) { who.SetPrefix(); } PlayerDB.Update(target, PlayerData.ColumnTColor, color); return(true); }
static void UpdateGroup(Player p) { Group grp = Group.Find(p.group.Permission); if (grp == null) { grp = DefaultRank; } p.group = grp; if (PlayerDB.FindColor(p).Length == 0 && p.color != grp.Color) { p.color = grp.Color; Entities.GlobalRespawn(p); } p.SetPrefix(); }