public override void Use(Player p, string message) { if (message != "") { Help(p); return; } bool cpSpawn = p.useCheckpointSpawn; ushort x = (ushort)(16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32); ushort y = (ushort)(32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32); ushort z = (ushort)(16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32); if (!p.Game.Referee && !p.Game.Infected && Server.zombie.RoundInProgress) { Server.zombie.InfectPlayer(p); } if (p.PlayingTntWars) { TntWarsGame game = TntWarsGame.GetTntWarsGame(p); if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers && game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null) { bool blue = game.FindPlayer(p).Blue; p.SendPos(0xFF, (ushort)((0.5 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32)), (ushort)((1 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32)), (ushort)((0.5 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32)), (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]), (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4])); return; } } p.SendPos(0xFF, x, y, z, p.level.rotx, p.level.roty); }
public override void Use(Player p, string message) { if (message.Length > 0) { Help(p); return; } bool cpSpawn = p.useCheckpointSpawn; Position pos; pos.X = 16 + (cpSpawn ? p.checkpointX : p.level.spawnx) * 32; pos.Y = 32 + (cpSpawn ? p.checkpointY : p.level.spawny) * 32; pos.Z = 16 + (cpSpawn ? p.checkpointZ : p.level.spawnz) * 32; byte yaw = cpSpawn ? p.checkpointRotX : p.level.rotx; byte pitch = cpSpawn ? p.checkpointRotY : p.level.roty; OnPlayerSpawningEvent.Call(p, ref pos, ref yaw, ref pitch, true); if (p.PlayingTntWars) { TntWarsGame game = TntWarsGame.GameIn(p); if (game.GameMode == TntWarsGame.TntWarsGameMode.TDM && game.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers && game.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && game.RedSpawn != null && game.BlueSpawn != null) { bool blue = game.FindPlayer(p).Blue; pos.X = 16 + (blue ? game.BlueSpawn[0] : game.RedSpawn[0]) * 32; pos.Y = 32 + (blue ? game.BlueSpawn[1] : game.RedSpawn[1]) * 32; pos.Z = 16 + (blue ? game.BlueSpawn[2] : game.RedSpawn[2]) * 32; yaw = (byte)(blue ? game.BlueSpawn[3] : game.RedSpawn[3]); pitch = (byte)(blue ? game.BlueSpawn[4] : game.RedSpawn[4]); } } p.SendPos(Entities.SelfID, pos, new Orientation(yaw, pitch)); }
public override void Use(Player p, string message) { if (message != "") { Help(p); return; } ushort x = (ushort)((0.5 + p.level.spawnx) * 32); ushort y = (ushort)((1 + p.level.spawny) * 32); ushort z = (ushort)((0.5 + p.level.spawnz) * 32); if (!p.referee) { if (!p.infected && Server.zombie.GameInProgess()) { Server.zombie.InfectPlayer(p); } } if (p.PlayingTntWars) { TntWarsGame it = TntWarsGame.GetTntWarsGame(p); if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM && it.GameStatus != TntWarsGame.TntWarsGameStatus.WaitingForPlayers && it.GameStatus != TntWarsGame.TntWarsGameStatus.Finished && it.RedSpawn != null && it.BlueSpawn != null) { unchecked { p.SendPos((byte)-1, (ushort)((0.5 + (it.FindPlayer(p).Blue ? it.BlueSpawn[0] : it.RedSpawn[0]) * 32)), (ushort)((1 + (it.FindPlayer(p).Blue ? it.BlueSpawn[1] : it.RedSpawn[1]) * 32)), (ushort)((0.5 + (it.FindPlayer(p).Blue ? it.BlueSpawn[2] : it.RedSpawn[2]) * 32)), (byte)(it.FindPlayer(p).Blue ? it.BlueSpawn[3] : it.RedSpawn[3]), (byte)(it.FindPlayer(p).Blue ? it.BlueSpawn[4] : it.RedSpawn[4])); return; } } } unchecked { p.SendPos((byte)-1, x, y, z, p.level.rotx, p.level.roty); } }
void HandleChat(byte[] buffer, int offset) { if (!loggedIn) { return; } byte continued = buffer[offset + 1]; string text = NetUtils.ReadString(buffer, offset + 2); LastAction = DateTime.UtcNow; if (FilterChat(ref text, continued)) { return; } if (text != "/afk" && IsAfk) { CmdAfk.ToggleAfk(this, ""); } // Typing //Command appears in chat as /command // Suggested by McMrCat if (text.StartsWith("//")) { text = text.Remove(0, 1); } else if (DoCommand(text)) { return; } // People who are muted can't speak or vote if (muted) { SendMessage("You are muted."); return; } //Muted: Only allow commands // Lava Survival map vote recorder if (Server.lava.HasPlayer(this) && Server.lava.HasVote(text.ToLower())) { if (Server.lava.AddVote(this, text.ToLower())) { SendMessage("Your vote for &5" + text.ToLower().Capitalize() + " %Shas been placed. Thanks!"); Server.lava.map.ChatLevelOps(name + " voted for &5" + text.ToLower().Capitalize() + "%S."); return; } else { SendMessage("&cYou already voted!"); return; } } // Filter out bad words if (ServerConfig.ProfanityFiltering) { text = ProfanityFilter.Parse(text); } if (IsHandledMessage(text)) { return; } // Put this after vote collection so that people can vote even when chat is moderated if (Server.chatmod && !voice) { SendMessage("Chat moderation is on, you cannot speak."); return; } if (ChatModes.Handle(this, text)) { return; } if (text[0] == ':' && PlayingTntWars) { string newtext = text.Remove(0, 1).Trim(); TntWarsGame it = TntWarsGame.GameIn(this); if (it.GameMode == TntWarsGame.TntWarsGameMode.TDM) { TntWarsGame.player pl = it.FindPlayer(this); foreach (TntWarsGame.player p in it.Players) { if (pl.Red && p.Red) { SendMessage(p.p, "To Team " + Colors.red + "-" + color + name + Colors.red + "- %S" + newtext); } if (pl.Blue && p.Blue) { SendMessage(p.p, "To Team " + Colors.blue + "-" + color + name + Colors.blue + "- %S" + newtext); } } Logger.Log(LogType.GameActivity, "[TNT Wars] [TeamChat (" + (pl.Red ? "Red" : "Blue") + ") " + name + " " + newtext); return; } } text = HandleJoker(text); if (Chatroom != null) { Chat.MessageChatRoom(this, text, true, Chatroom); return; } bool levelOnly = !level.SeesServerWideChat; string format = levelOnly ? "<{0}>[level] {1}" : "<{0}> {1}"; Logger.Log(LogType.PlayerChat, format, name, text); OnPlayerChatEvent.Call(this, text); if (cancelchat) { cancelchat = false; return; } if (levelOnly) { Chat.MessageLevel(this, text, true, level); } else { SendChatFrom(this, text); } CheckForMessageSpam(); }
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(); } }
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(); } }