From d9df2bf96266f716856db25853b183cc8d4a8061 Mon Sep 17 00:00:00 2001 From: Shank Date: Sun, 5 Jun 2011 22:37:56 -0600 Subject: [PATCH] Added /me Turned back on logger Stopped logging send message events(spam!) Closes #28 --- TShockAPI/Commands.cs | 11 +++++++---- TShockAPI/Log.cs | 2 +- TShockAPI/TShock.cs | 4 ++-- TShockAPI/Tools.cs | 13 +++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 16775975..a3362712 100644 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -102,10 +102,7 @@ namespace TShockAPI commands.Add(new Command("debug-config", "cfg", new CommandDelegate(DebugConfiguration))); commands.Add(new Command("playing", "", new CommandDelegate(Playing))); commands.Add(new Command("auth", "", new CommandDelegate(AuthToken))); - //TShock.admincommandList.Add("debug-config", new CommandDelegate(DebugConfiguration)); - //TShock.admincommandList.Add("playing", new CommandDelegate(Playing)); - //TShock.commandList.Add("help", new CommandDelegate(Help)); - //TShock.commandList.Add("playing", new CommandDelegate(Playing));); + commands.Add(new Command("me", "", new CommandDelegate(ThirdPerson))); if (ConfigurationManager.distributationAgent != "terraria-online") { commands.Add(new Command("kill", "kill", new CommandDelegate(Kill))); @@ -117,6 +114,12 @@ namespace TShockAPI #region Command Methods + public static void ThirdPerson(CommandArgs args) + { + string msg = args.Message.Remove(0, 3); + Tools.Broadcast("*" + Tools.FindPlayer(args.PlayerID) + " " + msg, new float[] {205, 133, 63 }); + } + public static void Playing(CommandArgs args) { Tools.SendMessage(args.PlayerID, Tools.GetPlayers()); diff --git a/TShockAPI/Log.cs b/TShockAPI/Log.cs index de1ca59e..d2d6f354 100644 --- a/TShockAPI/Log.cs +++ b/TShockAPI/Log.cs @@ -84,7 +84,7 @@ namespace TShockAPI String text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture) + " - " + caller + message; - //Console.WriteLine(text); + Console.WriteLine(text); if (!MayWriteType(level)) { diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 670c4853..a4b487e3 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -15,7 +15,7 @@ namespace TShockAPI public static string saveDir = "./tshock/"; - public static Version VersionNum = new Version(1, 9, 0, 0); + public static Version VersionNum = new Version(1, 8, 0, 1); public static string VersionCodename = "Squashing Bugs"; @@ -204,7 +204,7 @@ namespace TShockAPI var flag = CheckSpawn(x, y); if (flag) { - Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new float[] { 255f, 0f, 0f }); + Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", new float[] { 255f, 0f, 0f }); e.Handled = true; } } diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index 2fd0159c..6a4718dc 100644 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -85,6 +85,16 @@ namespace TShockAPI Log.Info("Broadcast: " + msg); } + + public static void Broadcast(string msg, float[] color) + { + for (int i = 0; i < Main.player.Length; i++) + { + SendMessage(i, msg, color); + } + Log.Info("Broadcast: " + msg); + } + /// /// Sends a message out to a single player /// @@ -94,7 +104,6 @@ namespace TShockAPI public static void SendMessage(int ply, string msg, float[] color) { NetMessage.SendData(0x19, ply, -1, msg, 255, color[0], color[1], color[2]); - Log.Info("Said: " + msg + " - To: " + Tools.FindPlayer(ply)); } /// @@ -105,7 +114,6 @@ namespace TShockAPI public static void SendMessage(int ply, string message) { NetMessage.SendData(0x19, ply, -1, message, 255, 0f, 255f, 0f); - Log.Info("Said: " + message + " - To: " + Tools.FindPlayer(ply)); } /// @@ -377,5 +385,6 @@ namespace TShockAPI } public Tools() { } + } } \ No newline at end of file