static bool GotoLevel(Player p, Level lvl) { if (p.level == lvl) { p.Message("You are already in {0}%S.", lvl.ColoredName); return(false); } bool canJoin = lvl.CanJoin(p); OnJoiningLevelEvent.Call(p, lvl, ref canJoin); if (!canJoin) { return(false); } p.Loading = true; Entities.DespawnEntities(p); Level prev = p.level; p.level = lvl; p.SendRawMap(prev, lvl); PostSentMap(p, prev, lvl, true); p.Loading = false; return(true); }
public static void ReloadMap(Player p, Player who, bool showMessage) { who.Loading = true; Entities.DespawnEntities(who); who.SendMap(who.level); Entities.SpawnEntities(who); who.Loading = false; if (!showMessage) { return; } if (p == null || !Entities.CanSee(who, p)) { who.SendMessage("&bMap reloaded"); } else { who.SendMessage("&bMap reloaded by " + p.ColoredName); } if (Entities.CanSee(p, who)) { Player.Message(p, "&4Finished reloading for " + who.ColoredName); } }
public static void ReloadFor(Player src, Player p, bool announce) { p.Loading = true; Entities.DespawnEntities(p); p.SendMap(p.level); Entities.SpawnEntities(p); p.Loading = false; if (!announce) { return; } if (src == null || !Entities.CanSee(p, src)) { p.Message("&bMap reloaded"); } else { p.Message("&bMap reloaded by " + src.ColoredName); } if (Entities.CanSee(src, p)) { src.Message("&4Finished reloading for " + p.ColoredName); } }
static bool GotoLevel(Player p, Level lvl) { if (p.level == lvl) { Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return(false); } if (!lvl.CanJoin(p)) { return(false); } p.Loading = true; Entities.DespawnEntities(p); Level oldLevel = p.level; p.level = lvl; p.SendMap(oldLevel); Position pos = lvl.SpawnPos; byte yaw = lvl.rotx, pitch = lvl.roty; OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, false); Entities.SpawnEntities(p, pos, new Orientation(yaw, pitch)); CheckGamesJoin(p, oldLevel); if (p.level.ShouldShowJoinMessage(oldLevel)) { string msg = p.level.IsMuseum ? " %Swent to the " : " %Swent to "; Chat.MessageGlobal(p, p.ColoredName + msg + lvl.ColoredName, false, true); OnPlayerActionEvent.Call(p, PlayerAction.JoinWorld, lvl.name); } return(true); }
internal static void ReloadMap(Player p) { p.Loading = true; Entities.DespawnEntities(p); p.SendRawMap(p.level, p.level); Entities.SpawnEntities(p, p.Pos, p.Rot); p.Loading = false; }
static bool GotoLevel(Player p, Level lvl) { if (p.level == lvl) { p.Message("You are already in {0}%S.", lvl.ColoredName); return(false); } if (!lvl.CanJoin(p)) { return(false); } p.Loading = true; Entities.DespawnEntities(p); Level oldLevel = p.level; p.level = lvl; p.SendMap(oldLevel); PostSentMap(p, oldLevel, lvl, true); return(true); }
public static void ReloadMap(Player p, Player who, bool showMessage) { who.Loading = true; Entities.DespawnEntities(who); who.SendUserMOTD(); who.SendMap(who.level); Entities.SpawnEntities(who); who.Loading = false; if (!showMessage) { return; } if (p != null && !p.hidden) { who.SendMessage("&bMap reloaded by " + p.name); } if (p != null && p.hidden) { who.SendMessage("&bMap reloaded"); } Player.Message(p, "&4Finished reloading for " + who.name); }
static bool GotoLevel(Player p, Level lvl, bool ignorePerms) { if (p.level == lvl) { Player.Message(p, "You are already in {0}%S.", lvl.ColoredName); return(false); } if (!lvl.CanJoin(p, ignorePerms)) { return(false); } if (!Server.zombie.PlayerCanJoinLevel(p, lvl, p.level)) { return(false); } p.Loading = true; Entities.DespawnEntities(p); Level oldLevel = p.level; p.level = lvl; p.SendUserMOTD(); p.SendMap(oldLevel); ushort x = (ushort)(lvl.spawnx * 32 + 16); ushort y = (ushort)(lvl.spawny * 32 + 32); ushort z = (ushort)(lvl.spawnz * 32 + 16); Entities.SpawnEntities(p, x, y, z, lvl.rotx, lvl.roty); p.Loading = false; CheckGamesJoin(p, oldLevel); p.prevMsg = ""; if (!p.hidden && p.level.ShouldShowJoinMessage(oldLevel)) { Player.SendChatFrom(p, p.ColoredName + " %Swent to " + lvl.ColoredName, false); Player.RaisePlayerAction(p, PlayerAction.JoinWorld, lvl.name); } return(true); }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer || IsSuper) { return; } leftServer = true; CriticalTasks.Clear(); ZoneIn = null; // Disconnected before sent handshake if (name == null) { if (Socket != null) { Socket.Close(); } Logger.Log(LogType.UserActivity, "{0} disconnected.", IP); return; } Server.reviewlist.Remove(name); try { if (Socket.Disconnected) { PlayerInfo.Online.Remove(this); return; } if (weapon != null) { weapon.Disable(); } if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Session.SendKick(kickPacketMsg, sync); Socket.Disconnected = true; ZoneIn = null; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { PlayerInfo.Online.Remove(this); Logger.Log(LogType.UserActivity, "{0} ({1}) disconnected. ({2})", truename, IP, discMsg); return; } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); SaveStats(); PlayerInfo.Online.Remove(this); OnPlayerDisconnectEvent.Call(this, discMsg); level.AutoUnload(); Dispose(); } catch (Exception e) { Logger.LogError("Error disconnecting player", e); } finally { Socket.Close(); } }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer) { return; } leftServer = true; CriticalTasks.Clear(); ZoneIn = null; // Disconnected before sent handshake if (name == null) { if (Socket != null) { Socket.Close(); } Logger.Log(LogType.UserActivity, "{0} disconnected.", ip); return; } Server.reviewlist.Remove(name); try { if (Socket.Disconnected) { PlayerInfo.Online.Remove(this); return; } // FlyBuffer.Clear(); LastAction = DateTime.UtcNow; IsAfk = false; isFlying = false; if (weapon != null) { weapon.Disable(); } if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Send(Packet.Kick(kickPacketMsg, hasCP437), sync); Socket.Disconnected = true; ZoneIn = null; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { PlayerInfo.Online.Remove(this); string user = name + " (" + ip + ")"; Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg); return; } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); save(); PlayerInfo.Online.Remove(this); OnPlayerDisconnectEvent.Call(this, discMsg); level.AutoUnload(); Dispose(); } catch (Exception e) { Logger.LogError("Error disconnecting player", e); } finally { Socket.Close(); } }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer) { return; } leftServer = true; CriticalTasks.Clear(); //Umm...fixed? if (name == null || name.Length == 0) { if (Socket != null) { CloseSocket(); } connections.Remove(this); disconnected = true; Logger.Log(LogType.UserActivity, "{0} disconnected.", ip); return; } Server.reviewlist.Remove(name); try { if (disconnected) { CloseSocket(); connections.Remove(this); PlayerInfo.Online.Remove(this); return; } // FlyBuffer.Clear(); LastAction = DateTime.UtcNow; IsAfk = false; isFlying = false; aiming = false; if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Send(Packet.Kick(kickPacketMsg, hasCP437), sync); disconnected = true; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { connections.Remove(this); RemoveFromPending(); PlayerInfo.Online.Remove(this); string user = name + " (" + ip + ")"; Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg); return; } if (Game.team != null) { Game.team.RemoveMember(this); } TntWarsGame tntwarsgame = TntWarsGame.GameIn(this); if (tntwarsgame != null) { tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this)); tntwarsgame.SendAllPlayersMessage("TNT Wars: " + ColoredName + " %Shas left TNT Wars!"); } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); save(); PlayerInfo.Online.Remove(this); Server.PlayerListUpdate(); OnPlayerDisconnectEvent.Call(this, discMsg); if (ServerConfig.AutoLoadMaps && level.Config.AutoUnload && !level.IsMuseum && !level.HasPlayers()) { level.Unload(true); } Dispose(); } catch (Exception e) { Logger.LogError(e); } finally { CloseSocket(); } }