public static bool ProcessMessage(int userId, string message, out string newMessage) { newMessage = ""; PlayerChat pc = CacheSet.PlayerChatCache.FindKey(userId.ToString(), userId); if (pc == null) { pc = new PlayerChat(); pc.UserId = userId; pc.LastWorldChatTime = 0; pc.Content = ""; CacheSet.PlayerChatCache.Add(pc); } int sizeLimit = GameConfigs.GetInt("World_Chat_Max_Length") == 0 ? 60 : GameConfigs.GetInt("World_Chat_Max_Length"); if (message.Length > sizeLimit) { return(false); } message = message.Trim(); if (string.IsNullOrEmpty(message)) { return(false); } newMessage = WordServer.Filter(message); return(true); }
public static bool SendWorld(Player sender, string message) { int time = GameConfigs.GetInt("World_Chat_CoolDown_Seconds", 30); PlayerChat pc = CacheSet.PlayerChatCache.FindKey(sender.Id.ToString(), sender.Id); if (DateTime.UtcNow.Ticks - pc.LastWorldChatTime < time * GameConsts.TicksPerSecond) { return(false); } byte[] buffer = GenPackage((int)ChatType.World, sender, message); var allOLUsers = GameSession.GetOnlineAll(); foreach (var user in allOLUsers) { user.SendAsync(buffer, 0, buffer.Length); } pc.LastWorldChatTime = DateTime.UtcNow.Ticks; return(true); }