Example #1
0
        public static bool OnChat(messageBuffer msg, int whoami, string text)
        {
            if (Chat == null)
                return false;

            var args = new HandledEventArgs();
            Chat(msg, whoami, text, args);
            return args.Handled;
        }
 public static bool OnChat(messageBuffer msg, int whoami, string text)
 {
     if (ServerHooks.Chat == null)
     {
         return false;
     }
     HandledEventArgs handledEventArgs = new HandledEventArgs();
     ServerHooks.Chat(msg, whoami, text, handledEventArgs);
     return handledEventArgs.Handled;
 }
Example #3
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (e.Handled)
                return;

            var player = QTools.GetPlayerByID(ply);
            if (player.AwaitingChat)
            {
                player.LastChatMessage = text;
                player.AwaitingChat = false;

                if (player.HideChat)
                    e.Handled = true;
            }
        }
 public static bool OnGetData(ref byte msgid, messageBuffer msg, ref int idx, ref int length)
 {
     if (NetHooks.GetData == null)
     {
         return false;
     }
     GetDataEventArgs getDataEventArgs = new GetDataEventArgs
     {
         MsgID = (PacketTypes)msgid,
         Msg = msg,
         Index = idx,
         Length = length
     };
     NetHooks.GetData(getDataEventArgs);
     msgid = (byte)getDataEventArgs.MsgID;
     idx = getDataEventArgs.Index;
     length = getDataEventArgs.Length;
     return getDataEventArgs.Handled;
 }
Example #5
0
        public static bool OnGetData(ref byte msgid, messageBuffer msg, ref int idx, ref int length)
        {
            if (GetData == null)
                return false;

            var args = new GetDataEventArgs()
            {
                MsgID = (PacketTypes)msgid,
                Msg = msg,
                Index = idx,
                Length = length
            };

            GetData(args);

            msgid = (byte)args.MsgID;
            idx = args.Index;
            length = args.Length;

            return args.Handled;
        }
Example #6
0
        public static void NetReceiveIntercept(messageBuffer msgBuffer, int msgType, int start, int length, ref int num)
        {
            if (msgType == 23 && Main.netMode==1)
            {
                int npcIndex = (int) BitConverter.ToInt16(msgBuffer.readBuffer, start + 1);
                if (num < start + length)
                {
                    int size = BitConverter.ToInt32(msgBuffer.readBuffer, num);
                    num += 4;
                    //Console.WriteLine("NPC Index " + npcIndex + ", size=" + size + ", index=" + num + ", start=" + start + ", length=" + length);

                    if (size > 0)
                    {
                        MemoryStream readStream = new MemoryStream(msgBuffer.readBuffer, num, size);

                        BinaryReader reader = new BinaryReader(readStream);

                        Main.npc[npcIndex].RunMethod("Load", reader, -1);
                        num += size;
                    }
                }
                //else Console.WriteLine("Invalid index: index=" + num + ", start=" + start + ", length=" + length);
            }
        }
Example #7
0
        private void OnChat(messageBuffer msgb, int pid, string msg, HandledEventArgs args)
        {
            if (args.Handled)
                return;

            TSPlayer sender = TShock.Players[msgb.whoAmI];
            if (sender == null)
            {
                args.Handled = true;
                return;
            }

            if (msg.StartsWith("!"))
            {
                args.Handled = true;
                string[] Messagearr = msg.Split(' ');
                string cmd = Messagearr[0].Substring(1);
                switch (cmd)
                {
                    case "red":
                        Chat(Color.Red, Messagearr,sender.Name);
                        break;
                    case "green":
                        Chat(Color.Green, Messagearr, sender.Name);
                        break;
                    case "whisp":
                        Whisper(sender, Messagearr);
                        break;

                    default:
                        sender.SendMessage("Erdbeerkäse =)");
                        break;

                }
            }
        }
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (text == "/")
                e.Handled = true;

            if (text.StartsWith("/") && text != "/=" && !text.StartsWith("/= ") && !text.StartsWith("/ "))
            {
                var player = GetesPlayerByID(ply);
                player.lastcmd = text;
            }

            if (text.StartsWith("/tp "))
            {
                #region /tp
                var player = TShock.Players[ply];
                if (player.Group.HasPermission("tp") && player.RealPlayer)
                {

                    List<string> parms = new List<string>();
                    string[] texts = text.Split(' ');
                    for (int i = 1; i < texts.Length; i++)
                    {
                        parms.Add(texts[i]);
                    }

                    string plStr = String.Join(" ", parms);
                    var players = TShock.Utils.FindPlayer(plStr);

                    if (parms.Count > 0 && players.Count == 1 && players[0].TPAllow && player.Group.HasPermission(Permissions.tpall))
                    {
                        esPlayer play = GetesPlayerByName(player.Name);
                        play.lastXtp = player.TileX;
                        play.lastYtp = player.TileY;
                        play.lastaction = "tp";
                    }
                }
                #endregion
            }
            else if (text == "/home" || text.StartsWith("/home "))
            {
                #region /home
                var player = TShock.Players[ply];
                if (player.Group.HasPermission("tp") && player.RealPlayer)
                {
                    esPlayer play = GetesPlayerByName(player.Name);
                    play.lastXtp = player.TileX;
                    play.lastYtp = player.TileY;
                    play.lastaction = "tp";
                }
                #endregion
            }
            else if (text == "/spawn" || text.StartsWith("/spawn "))
            {
                #region /spawn
                var player = TShock.Players[ply];
                if (player.Group.HasPermission("tp") && player.RealPlayer)
                {
                    esPlayer play = GetesPlayerByName(player.Name);
                    play.lastXtp = player.TileX;
                    play.lastYtp = player.TileY;
                    play.lastaction = "tp";
                }
                #endregion
            }
            else if (text.StartsWith("/warp "))
            {
                #region /warp
                var player = TShock.Players[ply];
                if (player.Group.HasPermission("warp"))
                {
                    List<string> parms = new List<string>();
                    string[] textsp = text.Split(' ');
                    for (int i = 1; i < textsp.Length; i++)
                    {
                        parms.Add(textsp[i]);
                    }

                    if (parms.Count > 0 && !parms[0].Equals("list"))
                    {
                        string warpName = String.Join(" ", parms);
                        var warp = TShock.Warps.FindWarp(warpName);
                        if (warp.WarpPos != Vector2.Zero)
                        {
                            esPlayer play = GetesPlayerByName(player.Name);
                            play.lastXtp = player.TileX;
                            play.lastYtp = player.TileY;
                            play.lastaction = "tp";
                        }
                    }
                }
                #endregion
            }
        }
Example #9
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (text[0] == '/')
                return;

            var tsplr = TShock.Players[msg.whoAmI];

            foreach (House house in HousingDistricts.Houses)
            {
                if (house.HouseArea.Intersects(new Rectangle(tsplr.TileX, tsplr.TileY, 1, 1)) && house.WorldID == Main.worldID.ToString())
                {
                    HTools.BroadcastToHouse(house.ID, text, tsplr.Name);
                    e.Handled = true;
                }
            }
        }
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string firstword = text.Split(' ')[0];
            TSPlayer player = GetTSPlayerByIndex(ply);

            if (firstword[0] == '/')
            {
                List<string> words = firstword.Split('/').ToList<string>();

                if (words.Count > 1)
                {
                    firstword = words[1];

                        foreach (CommandRedirect cmdr in Redirects)
                    {
                        if (cmdr.NewCmd == firstword)
                        {
                            List<string> parameters = text.Split(' ').ToList<string>();
                            parameters[0] = "/" + cmdr.TShockCmd;
                            string finalstring = "";
                            int count = 0;
                            foreach (string str in parameters)
                            {
                                if (count == 0)
                                    finalstring = str;
                                else
                                    finalstring = finalstring + " " + str;

                                count++;
                            }

                            Commands.HandleCommand(player, finalstring);

                            e.Handled = true;
                        }
                    }
                }
            }

            if (!TShock.Players[ply].Group.HasPermission("chatunblocked"))
            {

                if (StartsWith.Contains(text[0].ToString().ToLower()))
                {
                    foreach (Command cmd in Commands.ChatCommands)
                    {
                        if (cmd.Name.ToLower() == firstword.ToLower())
                            return;
                    }
                    e.Handled = true;
                }

                foreach (string word in text.Split(' '))
                {
                    if (Contains.Contains(word.ToLower()))
                    {
                        TShock.Players[ply].SendMessage(CConfig.BlockedWordMessage, Color.Red);
                        e.Handled = true;
                        return;
                    }
                }
            }
        }
 public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
 {
     string firstword = text.Split(' ')[0];
     if (firstword == "/login")
     {
         if (TShock.Players[ply].IsLoggedIn)
         {
             bool PlayerHasAnSPAccount = false;
             int count = SQLEditor.ReadColumn("ServerPointAccounts", "ID", new List<SqlValue>()).Count;
             object[] ServerPointAccounts = new object[count];
             SQLEditor.ReadColumn("ServerPointAccounts", "name", new List<SqlValue>()).CopyTo(ServerPointAccounts);
             for (int i = 0; i < count; i++)
             {
                 if (TShock.Players[ply].UserAccountName == ServerPointAccounts[i].ToString())
                 {
                     EPRPlayer player = GetEPRPlayerByIndex(ply);
                     if (player.Username != "" && player.AccountEnable)
                     {
                         List<SqlValue> where = new List<SqlValue>();
                         where.Add(new SqlValue("name", "'" + player.Username + "'"));
                         List<SqlValue> values = new List<SqlValue>();
                         values.Add(new SqlValue("amount", player.Account));
                         SQLEditor.UpdateValues("ServerPointAccounts", values, where);
                     }
                     player.Username = TShock.Players[ply].UserAccountName;
                     player.AccountEnable = true;
                     player.Account = 0;
                     List<SqlValue> where2 = new List<SqlValue>();
                     where2.Add(new SqlValue("name", "'" + TShock.Players[ply].UserAccountName.ToString() + "'"));
                     if (SQLEditor.ReadColumn("ServerPointAccounts", "amount", where2).Count > 0)
                     {
                         player.Account = int.Parse(SQLEditor.ReadColumn("ServerPointAccounts", "amount", where2)[0].ToString());
                     }
                     PlayerHasAnSPAccount = true;
                     break;
                 }
             }
             if (!PlayerHasAnSPAccount)
             {
                 int defaultbal = 0;
                 List<SqlValue> list = new List<SqlValue>();
                 list.Add(new SqlValue("name", "'" + TShock.Players[ply].UserAccountName.ToString() + "'"));
                 list.Add(new SqlValue("amount", defaultbal));
                 SQLEditor.InsertValues("ServerPointAccounts", list);
                 EPRPlayer player = GetEPRPlayerByIndex(ply);
                 if (player.Username != "" && player.AccountEnable)
                 {
                     List<SqlValue> where = new List<SqlValue>();
                     where.Add(new SqlValue("name", "'" + player.Username + "'"));
                     List<SqlValue> values = new List<SqlValue>();
                     values.Add(new SqlValue("amount", player.Account));
                     SQLEditor.UpdateValues("ServerPointAccounts", values, where);
                 }
                 player.Username = TShock.Players[ply].UserAccountName;
                 player.AccountEnable = true;
                 player.Account = 0;
                 TShock.Players[ply].SendMessage("A pouch was created for this account. You can now start accumulating " + currname + "s!", Color.Green);
             }
             #region hide this messy code
             //Tempaccounts.AddTempAccount(TempAccount(TShock.Players[ply].UserAccountName, ply));
             //List<string> AccountsToRemove = new List<string>();
             //foreach (TempAccount tempaccountctr in Tempaccounts.tempaccounts)
             //{
             //    if (AccountOwnerLoggedOnAdifferentAccount(tempaccountctr.AccountName))
             //    {
             //        AccountsToRemove.Add(tempaccountctr.AccountName);
             //        //Tempaccounts.RemoveAndUpdate(tempaccountctr.AccountName);
             //    }
             //}
             //if(AccountsToRemove.Count > 0)
             //{
             //    foreach (string accountname in AccountsToRemove)
             //    {
             //        Tempaccounts.RemoveAndUpdate(accountname);
             //    }
             //}
             //AccountsToRemove.Clear();
             #endregion
             for (int i = 0; i < TimeRewardPlayers.Count; i++)
             {
                 if (ply == TimeRewardPlayers[i].Index)
                     TimeRewardPlayers[i].LastReward = DateTime.Now;
             }
         }
     }
 }
Example #12
0
 public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
 {
 }
        public void OnChat(messageBuffer msg, int who, string text, HandledEventArgs e)
        {
            try
            {
                if (e.Handled)
                    return;
                if (text == "/")
                {
                    //TShock.Players[who].SendMessage("Yes, that is how you execute commands! type /help for a list of them!", Color.LightSeaGreen);
                    e.Handled = true;
                    return;
                }

                var ePly = esPlayers[who];
                var tPly = TShock.Players[who];

                if (text.StartsWith("/") && text != "/=" && !text.StartsWith("/= ") && !text.StartsWith("/ "))
                {
                    ePly.LastCMD = text;
                }

                if (text.StartsWith("/tp "))
                {
                    #region /tp
                    if (tPly.Group.HasPermission("tp") && tPly.RealPlayer)
                    {
                        /* Make sure the tp is valid */
                        List<string> Params = esUtils.ParseParameters(text);
                        Params.RemoveAt(0);

                        string plStr = String.Join(" ", Params);
                        var players = TShock.Utils.FindPlayer(plStr);

                        if (Params.Count > 0 && players.Count == 1 && players[0].TPAllow && tPly.Group.HasPermission(Permissions.tpall))
                        {
                            ePly.LastBackX = tPly.TileX;
                            ePly.LastBackY = tPly.TileY;
                            ePly.LastBackAction = BackAction.TP;
                        }
                    }
                    #endregion
                }
                else if (text == "/home" || text.StartsWith("/home "))
                {
                    #region /home
                    if (tPly.Group.HasPermission("home") && tPly.RealPlayer)
                    {
                        ePly.LastBackX = tPly.TileX;
                        ePly.LastBackY = tPly.TileY;
                        ePly.LastBackAction = BackAction.TP;
                    }
                    #endregion
                }
                else if (text == "/spawn" || text.StartsWith("/spawn "))
                {
                    #region /spawn
                    if (tPly.Group.HasPermission("spawn") && tPly.RealPlayer)
                    {
                        ePly.LastBackX = tPly.TileX;
                        ePly.LastBackY = tPly.TileY;
                        ePly.LastBackAction = BackAction.TP;
                    }
                    #endregion
                }
                else if (text.StartsWith("/warp "))
                {
                    #region /warp
                    if (tPly.Group.HasPermission("warp") && tPly.RealPlayer)
                    {
                        /* Make sure the warp is valid */
                        List<string> Params = esUtils.ParseParameters(text);
                        Params.RemoveAt(0);

                        if (Params.Count > 0 && !Params[0].Equals("list"))
                        {
                            string warpName = String.Join(" ", Params);
                            var warp = TShock.Warps.FindWarp(warpName);
                            if (warp != null && warp.WarpPos != Vector2.Zero)
                            {
                                ePly.LastBackX = tPly.TileX;
                                ePly.LastBackY = tPly.TileY;
                                ePly.LastBackAction = BackAction.TP;
                            }
                        }
                    }
                    #endregion
                }
                else if (text.StartsWith("/whisper ") || text.StartsWith("/w ") || text.StartsWith("/tell ") || text.StartsWith("/reply ") || text.StartsWith("/r ") || text.StartsWith("/p "))
                {
                    if (!tPly.Group.HasPermission("whisper")) return;
                    foreach (var player in esPlayers)
                    {
                        if (player == null || !player.SocialSpy || player == ePly) continue;
                        if ((text.StartsWith("/reply ") || text.StartsWith("/r ")) && tPly.LastWhisper != null)
                            player.TSPlayer.SendMessage(string.Format("[SocialSpy] from {0} to {1}: {2}", tPly.Name, tPly.LastWhisper.Name ?? "?", text), Color.Gray);
                        else
                            player.TSPlayer.SendMessage(string.Format("[SocialSpy] {0}: {1}", tPly.Name, text), Color.Gray);
                    }
                }
                else if (ePly.HasNickName && !text.StartsWith("/") && !tPly.mute)
                {
                    e.Handled = true;
                    string nick = getConfig.PrefixNicknamesWith + ePly.Nickname;
                    TShock.Utils.Broadcast(String.Format(TShock.Config.ChatFormat, tPly.Group.Name, tPly.Group.Prefix, nick, tPly.Group.Suffix, text),
                                    tPly.Group.R, tPly.Group.G, tPly.Group.B);
                }
                else if (ePly.HasNickName && text.StartsWith("/me ") && !tPly.mute)
                {
                    e.Handled = true;
                    string nick = getConfig.PrefixNicknamesWith + ePly.Nickname;
                    TShock.Utils.Broadcast(string.Format("*{0} {1}", nick, text.Remove(0, 4)), 205, 133, 63);
                }
            }
            catch { }
        }
Example #14
0
        private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            var tsplr = Players[msg.whoAmI];
            if (tsplr == null)
            {
                e.Handled = true;
                return;
            }

            if (msg.whoAmI != ply)
            {
                e.Handled = Tools.HandleGriefer(tsplr, "Faking Chat");
                return;
            }

            if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && Config.AdminChatEnabled)
            {
                Tools.Broadcast(TShock.Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
                                (byte)TShock.Config.AdminChatRGB[0], (byte)TShock.Config.AdminChatRGB[1], (byte)TShock.Config.AdminChatRGB[2]);
                e.Handled = true;
                return;
            }

            if (text.StartsWith("/"))
            {
                try
                {
                    e.Handled = Commands.HandleCommand(tsplr, text);
                }
                catch (Exception ex)
                {
                    Log.ConsoleError("Command exception");
                    Log.Error(ex.ToString());
                }
            }
            else
            {
                Log.Info(string.Format("{0} said: {1}", tsplr.Name, text));
            }
        }
Example #15
0
 private void OnChat(messageBuffer msg, int player, string text, HandledEventArgs e)
 {
     if (!irc.IsConnected) return;
     TSPlayer tsplr = TShock.Players[msg.whoAmI];
     if (tsplr == null)
         return;
     if (!TShock.Utils.ValidString(text))
         return;
     if (text.StartsWith("/"))
         return;
     if (tsplr.mute)
         return;
     irc.SendMessage(SendType.Message, settings["channel"], string.Format("({0}){1}: {2}",
         tsplr.Group.Name, tsplr.Name, text));
 }
Example #16
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            char[] text2 = text.ToCharArray();
            if (text2[0] == '/')
            {
                return;
            }
            TSPlayer player = GetTSPlayerByIndex(ply);

            if (Players[GetPlayerIndex(ply)].Smartized)
            {
                e.Handled = true;
                string[] words = text.ToLower().Split(' ');
                for (int i = 0; i < words.Length; i++)
                {
                    if (finder(words[i], "ur") == words[i] || finder(words[i], "yur") == words[i] || finder(words[i], "yer") == words[i] || finder(words[i], "er") == words[i] || finder(words[i], "u") == words[i] || finder(words[i], "you'r") == words[i])
                    {
                        if (words.Length - 1 > i && (words[i + 1] == "are" || words[i + 1] == "r"))
                        {
                            words[i] = finder(words[i], "you're");
                        }
                        else
                        {
                            words[i] = finder(words[i], "you");
                        }
                    }

                    if (finder(words[i], "hw") == words[i])
                    {
                        if (words.Length - 1 > i && (words[i + 1] == "?" || words[i + 1] == "are" || words[i + 1] == "can" || words[i + 1] == "r"))
                            words[i] = finder(words[i], "how");
                        else
                            words[i] = finder(words[i], "homework");
                    }

                    if (finder(words[i], "do") == words[i])
                        if (words.Length - 1 > i && words[i + 1] == "not")
                        {
                            words[i + 1] = "";
                            words[i] = finder(words[i], "don't");
                        }

                    for (int i2 = 0; i2 < readWordsList.SmarterFingers.Count; i2++)
                    {
                        try
                        {
                            List<string> stupid = readWordsList.SmarterFingers[i2].getOriginal();
                            List<string> smart = readWordsList.SmarterFingers[i2].getReplacement();
                            int index = smart.Count;
                            for (int i4 = 0; i4 < stupid.Count; i4++)
                            {
                                if (finder(words[i], stupid[i4].ToLower()) == words[i])
                                    words[i] = finder(words[i], smart[rnd.Next(index)]);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex.Message);
                            continue;
                        }
                    }
                }
                string textR = string.Join(" ", words);
                e.Handled = true;
                TShock.Utils.Broadcast(
                    string.Format(TShock.Config.ChatFormat, player.Group.Name, player.Group.Prefix, player.Name, player.Group.Suffix, textR),
                    player.Group.R, player.Group.G, player.Group.B);
                return;
            }
        }
Example #17
0
		internal bool InvokeServerChat(messageBuffer buffer, int who, string text)
		{
			ServerChatEventArgs args = new ServerChatEventArgs
			{
				Buffer = buffer,
				Who = who,
				Text = text
			};

			this.ServerChat.Invoke(args);
			return args.Handled;
		}
Example #18
0
		internal bool InvokeNetGetData(ref byte msgId, messageBuffer buffer, ref int index, ref int length)
		{
			if (Main.netMode != 2 && msgId == (byte)PacketTypes.ChatText && length > 3)
			{
				byte playerID = buffer.readBuffer[index];
				Color color = new Color(buffer.readBuffer[index + 1] << 16, buffer.readBuffer[index + 2] << 8, buffer.readBuffer[index + 3]);
				string @string = Encoding.UTF8.GetString(buffer.readBuffer, index + 4, length - 5);
				this.InvokeClientChatReceived(playerID, color, @string);
			}

			if (Main.netMode == 2)
			{
				switch ((PacketTypes) msgId)
				{
					case PacketTypes.ConnectRequest:
						if (this.InvokeServerConnect(buffer.whoAmI))
						{
							Netplay.serverSock[buffer.whoAmI].kill = true;
							return true;
						}

						break;
					case PacketTypes.ContinueConnecting2:
						if (this.InvokeServerJoin(buffer.whoAmI))
						{
							Netplay.serverSock[buffer.whoAmI].kill = true;
							return true;
						}

						break;
					case PacketTypes.ChatText:
						string @string = Encoding.UTF8.GetString(buffer.readBuffer, index + 4, length - 5);
						if (this.InvokeServerChat(buffer, buffer.whoAmI, @string))
							return true;

						break;

					case PacketTypes.ClientUUID:
						byte[] uuid = new byte[length - 5];
						Buffer.BlockCopy(buffer.readBuffer, index + 4, uuid, 0, length - 5);
						SHA512 shaM = new SHA512Managed();
						var result = shaM.ComputeHash(uuid);
						Netplay.serverSock[buffer.whoAmI].clientUUID = result.Aggregate("", (s, b) => s + b.ToString("X2"));;
						return true;

						break;
				}
			}

			GetDataEventArgs args = new GetDataEventArgs
			{
				MsgID = (PacketTypes)msgId, 
				Msg = buffer, 
				Index = index, 
				Length = length
			};

			this.NetGetData.Invoke(args);

			msgId = (byte)args.MsgID;
			index = args.Index;
			length = args.Length;
			return args.Handled;
		}
Example #19
0
        private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (Main.netMode != 2 || e.Handled)
                return;

            if (msg.whoAmI != ply)
            {
                e.Handled = Tools.HandleGriefer(Players[ply], "Faking Chat");
                return;
            }

            var tsplr = Players[msg.whoAmI];

            if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/"))
            {
                Tools.Broadcast(ConfigurationManager.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
                                (byte)ConfigurationManager.AdminChatRGB[0], (byte)ConfigurationManager.AdminChatRGB[1], (byte)ConfigurationManager.AdminChatRGB[2]);
                e.Handled = true;
                return;
            }

            if (text.StartsWith("/"))
            {
                if (Commands.HandleCommand(tsplr, text))
                    e.Handled = true;
            }
            else
            {
                Log.Info(string.Format("{0} said: {1}", tsplr.Name, text));
            }
        }
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (findIfPlayingCommand(text) && !TShock.Players[ply].Group.HasPermission("ghostmode"))
            {

                string sb = "";
                foreach (TSPlayer player in TShock.Players)
                {
                    if (player != null && player.Active && !isGhost[player.Index])
                    {
                        if (sb.Length != 0)
                        {
                            sb += ", ";
                        }
                        sb += player.Name;
                    }
                }
                TShock.Players[ply].SendMessage(string.Format("Current players: {0}.", sb), 255, 240, 20);
                e.Handled = true;

            }
            if (((muted[ply]) && (findIfMeCommand(text))) || ((muteAll) && (!TShock.Players[ply].Group.HasPermission("mute"))))
            {

                TShock.Players[ply].SendMessage("You cannot use the /me command, you are muted.", Color.Red);
                e.Handled = true;
                return;

            }
            if (text.StartsWith("/tp "))
            {

                string tempText = text;
                tempText = tempText.Remove(0, 1);
                parseParameters(tempText);

            }
            if ((muted[ply] || muteAll) && !TShock.Players[ply].Group.HasPermission("mute"))
            {

                var tsplr = TShock.Players[msg.whoAmI];
                if (text.StartsWith("/"))
                {
                    try
                    {
                        Commands.HandleCommand(tsplr, text);
                    }
                    catch (Exception ex)
                    {
                        Log.ConsoleError("Command exception");
                        Log.Error(ex.ToString());
                    }
                }
                else
                {

                    if (!muteAll)
                    {
                        if (muteTime[tsplr.Index] <= 0)
                        {
                            tsplr.SendMessage("You have been muted by an admin.", Color.Red);
                        }
                        else
                        {
                            tsplr.SendMessage("You have " + muteTime[tsplr.Index].ToString() + " seconds left of muting.", Color.Red);
                        }
                    }
                    else
                    {

                        tsplr.SendMessage("The server is now muted for this reason: " + muteAllReason, Color.Red);

                    }

                }
                e.Handled = true;

            }
        }
Example #21
0
        private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (e.Handled)
                return;

            var tsplr = Players[msg.whoAmI];
            if (tsplr == null)
            {
                e.Handled = true;
                return;
            }

            /*if (!Utils.ValidString(text))
            {
                e.Handled = true;
                return;
            }*/

            if (text.StartsWith("/"))
            {
                try
                {
                    e.Handled = Commands.HandleCommand(tsplr, text);
                }
                catch (Exception ex)
                {
                    Log.ConsoleError("Command exception");
                    Log.Error(ex.ToString());
                }
            }
            else if (!tsplr.mute)
            {
                Utils.Broadcast(
                    String.Format(Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, text),
                    tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
                e.Handled = true;
            }
            else if (tsplr.mute)
            {
                tsplr.SendMessage("You are muted!");
                e.Handled = true;
            }
        }
Example #22
0
        public void OnChat(messageBuffer buffer, int who, string text, System.ComponentModel.HandledEventArgs args)
        {
            if (args.Handled)
                return;
            if (text.StartsWith("/login"))
            {
                if (text.Length > 7 && TShock.Players[who].UserID != -1)
                {
                    var player = GetPlayerByUserID(TShock.Players[who].UserID);
                    if (player != null)
                    {
                        try
                        {
                            AdminToolsMain.db.QueryReader("UPDATE PlayerData SET Nicknames=@1, IPs=@2, LastSeen=@3 WHERE UserID=@0", player.UserID, JsonConvert.SerializeObject(player.Nicknames, Formatting.None), JsonConvert.SerializeObject(player.IP, Formatting.None), DateTime.Now.Ticks);

                            lock (PlayerList)
                            {
                                PlayerList.Remove(player);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.ConsoleError(ex.ToString());
                        }
                    }
                    LoginThread lt = new LoginThread(who);
                    Thread t = new Thread(new ThreadStart(lt.CheckLogin));
                    t.Start();
                }
            }
        }
Example #23
0
 public void onChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
 {
     if (ply == player.Index)
     {
         Message = text;
         if (hideMessage)
             e.Handled = true;
     }
 }
Example #24
0
 public void OnChat(messageBuffer buffer, int who, string text, HandledEventArgs args)
 {
     var player = PlayerList[who];
     if (player != null)
     {
         if (text.StartsWith("/login") && player.TSplayer.UserID != player.UserID)
         {
            // Console.WriteLine("player.userID: {0}, TSplayer.userID: {1}", player.UserID, player.TSplayer.UserID);
             if (player.UserID != -1)
             {
                 int factid = 0;
                 if (player.Faction != null)
                     factid = player.Faction.ID;
                 db.Query("UPDATE factions_Players SET Power = @0, Faction = @1 WHERE UserID = @2 AND WorldID = @3", player.Power, factid, player.UserID, Main.worldID);
                 player.StopUpdating();
             }
             using (QueryResult reader = db.QueryReader("SELECT * FROM factions_Players WHERE UserID = @0 AND WorldID = @1", player.TSplayer.UserID, Main.worldID))
             {
                 if (reader.Read())
                 {
                     var faction = Faction.GetFactionByID(reader.Get<int>("Faction"));
                     PlayerList[who] = new Player(who, reader.Get<int>("Power"), faction);
                     reader.Dispose();
                     db.Query("UPDATE factions_Players SET Online = 1 WHERE UserID = @0 AND WorldID = @1", player.TSplayer.UserID, Main.worldID);
                 }
                 else
                 {
                     reader.Dispose();
                     db.Query("INSERT INTO factions_Players (UserID, Name, Power, Online, OfflineCount, Faction, WorldID) VALUES (@0, @1, 10, 1, 0, 0, @2)", player.TSplayer.UserID, player.TSplayer.UserAccountName, Main.worldID);
                     PlayerList[who] = new Player(who, 10, null);
                 }
             }
             PlayerList[who].StartUpdating();
         }
     }
 }
Example #25
0
 public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
 {
     string name = TShock.Players[ply].Name.ToLower();
     var ListedPlayer = Player.GetPlayerByName(name);
     if (ListedPlayer.GetBan() == Player.Banned.banned)
     {
         if (text.Trim().StartsWith("/"))
         {
             string[] textsplit = text.Trim().ToLower().Split(' ');
             if (textsplit[0] == "/dispute")
             {
                 return;
             }
             else
             {
                 TShock.Players[ply].SendMessage("Banned people cannot execute commands.", Color.Red);
                 TShock.Players[ply].SendMessage("If you wish to dispute your ban, type \"/dispute\".", Color.Red);
                 e.Handled = true;
                 return;
             }
         }
         else
         {
             TShock.Players[ply].SendMessage("Banned people cannot talk.", Color.Red);
             TShock.Players[ply].SendMessage("If you wish to dispute your ban, type \"/dispute\".", Color.Red);
             e.Handled = true;
             return;
         }
     }
     return;
 }
Example #26
0
        private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            if (e.Handled)
                return;

            var tsplr = Players[msg.whoAmI];
            if (tsplr == null)
            {
                e.Handled = true;
                return;
            }

            if (!Tools.ValidString(text))
            {
                Tools.Kick(tsplr, "Unprintable character in chat");
                e.Handled = true;
                return;
            }

            if (msg.whoAmI != ply)
            {
                e.Handled = Tools.HandleGriefer(tsplr, "Faking Chat");
                return;
            }

            if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && Config.AdminChatEnabled)
            {
                Tools.Broadcast(Config.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
                                tsplr.Group.R, tsplr.Group.G,
                                tsplr.Group.B);
                e.Handled = true;
                return;
            }

            if (text.StartsWith("/"))
            {
                try
                {
                    e.Handled = Commands.HandleCommand(tsplr, text);
                }
                catch (Exception ex)
                {
                    Log.ConsoleError("Command exception");
                    Log.Error(ex.ToString());
                }
            }
            else
            {
                Tools.Broadcast("{2}<{0}> {1}".SFormat(tsplr.Name, text, Config.ChatDisplayGroup ? "[{0}] ".SFormat(tsplr.Group.Name) : ""),
                                tsplr.Group.R, tsplr.Group.G,
                                tsplr.Group.B);
                //Log.Info(string.Format("{0} said: {1}", tsplr.Name, text));
                e.Handled = true;
            }
        }
Example #27
0
        private void OnChat(messageBuffer msgb, int who, string text, HandledEventArgs e)
        {
            if (e.Handled || !text.StartsWith("/"))
                return;

            foreach (var command in getConfig.commands)
            {
                if ((text == command.command || text.StartsWith(command.command + " ")) && command.file != "")
                {
                    e.Handled = true;
                    Log.Info("{0} executed: {1}".SFormat(TShock.Players[who].Name, command.command));
                    ShowFile(command, text, TShock.Players[who]);
                    break;
                }
            }
        }
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text.Split(' ')[0];
            var tsplr = TShock.Players[msg.whoAmI];
            if (cmd == "/warp")
            {
                if (text.Split(' ').Length > 1)
                {
                    if (TShock.Warps.FindWarp(text.Split(' ')[1]).WarpPos != Vector2.Zero)
                    {
                        if (Players[GetPlayerIndex(ply)].rulesMode && !tsplr.Group.HasPermission("jail") && TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) != "jail" && JPConfig.jailmode)
                        {
                            tsplr.SendMessage("You Can't Teleport Without Reading / Following The Rules!", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        if (TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) == "jail" && !tsplr.Group.HasPermission("jail") && Players[GetPlayerIndex(ply)].rulesMode && JPConfig.jailmode)
                        {
                            tsplr.SendMessage("You Can't Exit Jail Without Reading / Following The Rules!", Color.Red);
                            e.Handled = true;
                            return;
                        }
                        if (Players[GetPlayerIndex(ply)].prisonMode && JPConfig.prisonmode)
                        {
                            tsplr.SendMessage("You are stuck in prison - An Admin or Mod Will Need To Let You Out...");
                            e.Handled = true;
                            return;
                        }
                    }
                    else return;
                }
                return;
            }

            else if (cmd == "/tp")
            {
                if (text.Split(' ').Length > 1)
                {
                    if (Players[GetPlayerIndex(ply)].rulesMode && !tsplr.Group.HasPermission("jail") && TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) != "jail" && JPConfig.jailmode)
                    {
                        tsplr.SendMessage("You Can't Teleport Without Reading / Following The Rules!", Color.Red);
                        e.Handled = true;
                        return;
                    }
                    if (TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) == "jail" && !tsplr.Group.HasPermission("jail") && Players[GetPlayerIndex(ply)].rulesMode && JPConfig.jailmode)
                    {
                        tsplr.SendMessage("You Can't Exit Jail Without Reading / Following The Rules!", Color.Red);
                        e.Handled = true;
                        return;
                    }
                    if (Players[GetPlayerIndex(ply)].prisonMode && JPConfig.prisonmode)
                    {
                        tsplr.SendMessage("You are stuck in prison - An Admin or Mod Will Need To Let You Out...");
                        e.Handled = true;
                        return;
                    }
                }
                else return;
            }
            else if (cmd == "/home")
            {
                if (Players[GetPlayerIndex(ply)].rulesMode && !tsplr.Group.HasPermission("jail") && TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) != "jail" && JPConfig.jailmode)
                {
                    tsplr.SendMessage("You Can't Teleport Without Reading / Following The Rules!", Color.Red);
                    e.Handled = true;
                    return;
                }
                if (TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) == "jail" && !tsplr.Group.HasPermission("jail") && Players[GetPlayerIndex(ply)].rulesMode && JPConfig.jailmode)
                {
                    tsplr.SendMessage("You Can't Exit Jail Without Reading / Following The Rules!", Color.Red);
                    e.Handled = true;
                    return;
                }
                if (Players[GetPlayerIndex(ply)].prisonMode && JPConfig.prisonmode)
                {
                    tsplr.SendMessage("You are stuck in prison - An Admin or Mod Will Need To Let You Out...");
                    e.Handled = true;
                    return;
                }
                tsplr.Spawn();
                tsplr.SendMessage("Teleported to your spawnpoint.");
                e.Handled = true;
                return;
            }

            else if (cmd == "/spawn")
            {
                if (Players[GetPlayerIndex(ply)].rulesMode && !tsplr.Group.HasPermission("jail") && TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) != "jail" && JPConfig.jailmode)
                {
                    tsplr.SendMessage("You Can't Teleport Without Reading / Following The Rules!", Color.Red);
                    e.Handled = true;
                    return;
                }
                if (TShock.Regions.InAreaRegionName(tsplr.TileX, tsplr.TileY) == "jail" && !tsplr.Group.HasPermission("jail") && Players[GetPlayerIndex(ply)].rulesMode && JPConfig.jailmode)
                {
                    tsplr.SendMessage("You Can't Exit Jail Without Reading / Following The Rules!", Color.Red);
                    e.Handled = true;
                    return;
                }
                if (Players[GetPlayerIndex(ply)].prisonMode && JPConfig.prisonmode)
                {
                    tsplr.SendMessage("You are stuck in prison - An Admin or Mod Will Need To Let You Out...");
                    e.Handled = true;
                    return;
                }
                else
                {
                    var warp = TShock.Warps.FindWarp("spawn");
                    if (tsplr.Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3))
                        tsplr.SendMessage("Teleported to the map's spawnpoint.");
                    e.Handled = true;
                    return;
                }
            }
        }
Example #29
0
        public void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            string cmd = text.Split(' ')[0];
            if (cmd == "/duel" && TShockAPI.TShock.Utils.FindPlayer(text.Split(' ')[1]).Count == 1)
            {
                TSPlayer challenged = TShockAPI.TShock.Utils.FindPlayer(text.Split(' ')[1])[0];
                TSPlayer challenger = TShock.Players[ply];
                if (challenger.IsLoggedIn && challenged.IsLoggedIn)
                {
                    int challengerbal =
                        ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenger.Index).DisplayAccount;
                    if (challengerbal >= GetCEPlayer(ply).Bet)
                    {
                        GetCEPlayer(ply).challenged = challenged.Index;
                        challenger.SendMessage(
                            "You challenged " + challenged.Name + " to a duel for " + GetCEPlayer(ply).Bet.ToString() +
                            " " + ServerPointSystem.ServerPointSystem.currname + "s", Color.Teal);
                        challenger.SendMessage(
                            challenger.Name + " has  challenged you" + challenged.Name + " to a duel for " +
                            GetCEPlayer(ply).Bet.ToString() + " " + ServerPointSystem.ServerPointSystem.currname + "s",
                            Color.Teal);
                        foreach (CEPlayer ceplayerctr in WhoChallengedThisGuy(challenged.Index))
                        {
                            if (ceplayerctr.ID != ply)
                                GetCEPlayer(ceplayerctr.ID).challenged = -1;
                        }
                    }
                    else
                    {
                        e.Handled = true;
                        challenger.SendMessage(
                            "You don't have enough " + ServerPointSystem.ServerPointSystem.currname +
                            "s to do that! Lower your bet", Color.Red);
                    }
                }
                return;
            }
            else if (cmd == "/accept")
            {
                if (WhoChallengedThisGuy(ply).Count > 0)
                {
                    TSPlayer challenger = TShock.Players[WhoChallengedThisGuy(ply)[0].ID];
                    TSPlayer challenged = TShock.Players[ply];
                    EPRPlayer Echallenger = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenger.Index);
                    EPRPlayer Echallenged = ServerPointSystem.ServerPointSystem.GetEPRPlayerByIndex(challenged.Index);
                    if (challenger.IsLoggedIn && challenged.IsLoggedIn)
                    {
                        int challengerbal = Echallenger.DisplayAccount;
                        int challengedbal = Echallenged.DisplayAccount;
                        int wager = GetCEPlayer(challenger.Index).Bet;
                        if (challengerbal >= wager && challengedbal >= wager)
                        {
                            GetCEPlayer(challenged.Index).DuelReward = wager;
                            GetCEPlayer(challenger.Index).DuelReward = wager;
                            EPREvents.PointUse(Echallenger, wager, PointUsage.Bet);
                            EPREvents.PointUse(Echallenged, wager, PointUsage.Bet);

                        }
                        else
                        {
                            challenger.SendMessage(
                                "Error processing dueling bets. Either you or your opponent does not have enough " +
                                ServerPointSystem.ServerPointSystem.currname + "s", Color.Red);
                            challenged.SendMessage(
                                "Error processing dueling bets. Either you or your opponent does not have enough " +
                                ServerPointSystem.ServerPointSystem.currname + "s", Color.Red);
                            e.Handled = true;
                        }
                    }
                }
                return;
            }
            return;
        }
Example #30
0
        private void OnChat(messageBuffer msg, int ply, string text, HandledEventArgs e)
        {
            Rectangle rect;
            rect = new Rectangle();

            if (e.Handled)
                return;

            var tsplr = Players[msg.whoAmI];
            if (tsplr == null)
            {
                e.Handled = true;
                return;
            }
            /*Encoding win1251 = Encoding.GetEncoding("Windows-1251");
            char[] cArray = System.Text.Encoding.UTF8.GetChars(msg.readBuffer, 8, msg.messageLength);
            foreach (char c in cArray)
            {
                Console.WriteLine(Transliteration.Front(c.ToString()));
            }*/
            /*if (!Utils.ValidString(text))
            {
                e.Handled = true;
                return;
            }*/

            if (text.StartsWith("/"))
            {
                foreach (TSPlayer Player in TShock.Players)
                {
                    if (Player != null && Player.Active && Player.Group.HasPermission(Permissions.adminchat))
                        Player.SendMessage(string.Format("*<{0}> /{1}", tsplr.Name, text.Remove(0, 1)), Color.Red);
                }
                Console.WriteLine(string.Format("*<{0}> /{1}", tsplr.Name, text.Remove(0, 1)));
                Log.Info(string.Format("*<{0}> /{1}", tsplr.Name, text.Remove(0, 1)));
                try
                {
                    e.Handled = Commands.HandleCommand(tsplr, text);
                }
                catch (Exception ex)
                {
                    Log.ConsoleError("Command exception");
                    Log.Error(ex.ToString());
                }
                e.Handled = true;
            }
            else if (!tsplr.mute)
            {
                Chat.AddMessage(tsplr.Name, "", text);
                rect = new Rectangle((tsplr.TileX - 50), (tsplr.TileY - 50), 100, 100);
                foreach (TSPlayer Player in TShock.Players)
                {
                    if (Player != null && Player.Active)
                    {
                        if (Player.DisplayChat && Player.Group.HasPermission(Permissions.adminstatus))
                        {
                            Player.SendMessage("(Ranged){2}<{0}> {1}".SFormat(tsplr.Name, text, Config.ChatDisplayGroup ? "[{0}] ".SFormat(tsplr.Group.Name) : ""),
                                                                      tsplr.Group.R, tsplr.Group.G,
                                                                      tsplr.Group.B);
                        }
                        else
                            if (Player.TileX >= rect.Left && Player.TileX <= rect.Right &&
                                Player.TileY >= rect.Top && Player.TileY <= rect.Bottom)
                            {
                                Player.SendMessage("{2}<{0}> {1}".SFormat(tsplr.Name, text, Config.ChatDisplayGroup ? "[{0}] ".SFormat(tsplr.Group.Name) : ""),
                                tsplr.Group.R, tsplr.Group.G,
                                tsplr.Group.B);
                            }
                    }
                }
                Console.WriteLine(string.Format("{0} said: {1}", tsplr.Name, text));
                Log.Info(string.Format("{0} said: {1}", tsplr.Name, text));
            }
            else if (tsplr.mute)
            {
                tsplr.SendMessage("You are muted!");
                e.Handled = true;
            }
            e.Handled = true;
        }