/// <summary> Disconnects the players from the server, /// with their default logout message shown in chat. </summary> public void Disconnect() { LeaveServer(PlayerDB.GetLogoutMessage(this), "disconnected", false); }
void CompleteLoginProcess() { Player clone = null; OnPlayerFinishConnectingEvent.Call(this); if (cancelconnecting) { cancelconnecting = false; return; } lock (PlayerInfo.Online.locker) { // Check if any players online have same name Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (pl.truename == truename) { clone = pl; break; } } // Remove clone from list (hold lock for as short time as possible) if (clone != null && Server.Config.VerifyNames) { PlayerInfo.Online.Remove(clone); } id = NextFreeId(); PlayerInfo.Online.Add(this); } if (clone != null && Server.Config.VerifyNames) { string reason = ip == clone.ip ? "(Reconnecting)" : "(Reconnecting from a different IP)"; clone.Leave(reason); } else if (clone != null) { Leave(null, "Already logged in!", true); return; } SendRawMap(null, level); if (Socket.Disconnected) { return; } loggedIn = true; SessionStartTime = DateTime.UtcNow; LastLogin = DateTime.Now; TotalTime = TimeSpan.FromSeconds(1); GetPlayerStats(); ShowWelcome(); Server.Background.QueueOnce(ShowAltsTask, name, TimeSpan.Zero); CheckState(); if (!Directory.Exists("players")) { Directory.CreateDirectory("players"); } PlayerDB.Load(this); Game.Team = Team.TeamIn(this); SetPrefix(); LoadCpeData(); if (Server.noEmotes.Contains(name)) { parseEmotes = !Server.Config.ParseEmotes; } hideRank = Rank; hidden = CanUse("Hide") && Server.hidden.Contains(name); if (hidden) { Message("&8Reminder: You are still hidden."); } if (Chat.AdminchatPerms.UsableBy(Rank) && Server.Config.AdminsJoinSilently) { hidden = true; adminchat = true; } OnPlayerConnectEvent.Call(this); if (cancellogin) { cancellogin = false; return; } string joinMsg = "&a+ λFULL %S" + PlayerDB.GetLoginMessage(this); if (hidden) { joinMsg = "&8(hidden)" + joinMsg; } if (Server.Config.GuestJoinsNotify || Rank > LevelPermission.Guest) { Chat.MessageFrom(ChatScope.All, this, joinMsg, null, Chat.FilterVisible(this), !hidden); } if (Server.Config.AgreeToRulesOnEntry && Rank == LevelPermission.Guest && !Server.agreed.Contains(name)) { Message("&9You must read the &c/Rules &9and &c/Agree &9to them before you can build and use commands!"); agreed = false; } CheckIsUnverified(); if (CanUse("Inbox") && Database.TableExists("Inbox" + name)) { int count = Database.CountRows("Inbox" + name); if (count > 0) { Message("You have &a" + count + " %Smessages in %T/Inbox"); } } if (Server.Config.PositionUpdateInterval > 1000) { Message("Lowlag mode is currently &aON."); } if (String.IsNullOrEmpty(appName)) { Logger.Log(LogType.UserActivity, "{0} [{1}] connected.", name, ip); } else { Logger.Log(LogType.UserActivity, "{0} [{1}] connected using {2}.", name, ip, appName); } PlayerActions.PostSentMap(this, null, level, false); Loading = false; }
/// <summary> Calculates default color for the given player. </summary> public static string DefaultColor(Player p) { string col = PlayerDB.FindColor(p); return(col.Length > 0 ? col : p.group.Color); }
public static string FindOfflineIPMatches(Player p, string name, out string ip) { string[] match = PlayerDB.MatchValues(p, name, "Name,IP"); ip = match == null ? null : match[1]; return(match == null ? null : match[0]); }