public bool MarkPossessed(string marker = "") { if (marker.Length > 0) { Player controller = PlayerInfo.FindExact(marker); if (controller == null) { return(false); } marker = " (" + controller.color + controller.name + color + ")"; } Entities.GlobalDespawn(this, true); Entities.GlobalSpawn(this, true, marker); return(true); }
public void LeaveServer(string kickMsg, string discMsg, bool sync = false) { if (discMsg != null) { discMsg = Colors.EscapeColors(discMsg); } if (kickMsg != null) { kickMsg = Colors.EscapeColors(kickMsg); } OnPlayerDisconnectEvent.Call(this, discMsg ?? kickMsg); //Umm...fixed? if (name == "") { if (socket != null) { CloseSocket(); } connections.Remove(this); SaveUndo(this); disconnected = true; return; } Server.reviewlist.Remove(name); try { if (disconnected) { CloseSocket(); connections.Remove(this); return; } // FlyBuffer.Clear(); disconnected = true; SaveIgnores(); pingTimer.Stop(); pingTimer.Dispose(); afkTimer.Stop(); afkTimer.Dispose(); muteTimer.Stop(); muteTimer.Dispose(); timespent.Stop(); timespent.Dispose(); afkCount = 0; afkStart = DateTime.Now; Server.afkset.Remove(name); isFlying = false; aiming = false; SendKick(kickMsg, sync); if (!loggedIn) { connections.Remove(this); RemoveFromPending(); Server.s.Log(ip + " disconnected."); return; } Server.zombie.PlayerLeftServer(this); if (Game.team != null) { Game.team.RemoveMember(this); } Server.Countdown.PlayerLeftServer(this); TntWarsGame tntwarsgame = TntWarsGame.GetTntWarsGame(this); if (tntwarsgame != null) { tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this)); tntwarsgame.SendAllPlayersMessage("TNT Wars: " + color + name + Server.DefaultColor + " has left TNT Wars!"); } Entities.GlobalDespawn(this, false, true); if (discMsg != null) { if (!hidden) { string leavem = "&c- " + FullName + " %S" + discMsg; if ((Server.guestLeaveNotify && group.Permission <= LevelPermission.Guest) || group.Permission > LevelPermission.Guest) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { Player.SendMessage(pl, leavem); } } } Server.s.Log(name + "disconnected (" + discMsg + ")."); } else { totalKicked++; SendChatFrom(this, "&c- " + color + prefix + DisplayName + " %Skicked (" + kickMsg + "%S).", false); Server.s.Log(name + " kicked (" + kickMsg + ")."); } try { save(); } catch (Exception e) { Server.ErrorLog(e); } PlayerInfo.Online.Remove(this); Server.s.PlayerListUpdate(); if (name != null) { left[name.ToLower()] = ip; } if (PlayerDisconnect != null) { PlayerDisconnect(this, discMsg ?? kickMsg); } if (Server.AutoLoad && level.unload && !level.IsMuseum && IsAloneOnCurrentLevel()) { level.Unload(true); } Dispose(); } catch (Exception e) { Server.ErrorLog(e); } finally { CloseSocket(); } }
public static void GlobalDespawn(Player p, bool self) { Entities.GlobalDespawn(p, self); }