Advertisement
Guest User

chatmanager.cs

a guest
Feb 24th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using log4net;
  6. using wServer.realm.entities;
  7. using wServer.networking.svrPackets;
  8. using wServer.realm.entities.player;
  9. using wServer.networking;
  10.  
  11. namespace wServer.realm
  12. {
  13. public class ChatManager
  14. {
  15. static ILog log = LogManager.GetLogger(typeof(ChatManager));
  16.  
  17. RealmManager manager;
  18. public ChatManager(RealmManager manager)
  19. {
  20. this.manager = manager;
  21. }
  22.  
  23. public void Say(Player src, string text)
  24. {
  25. src.Owner.BroadcastPacketSync(new TextPacket()
  26. {
  27. Name = (src.Client.Account.Rank >= 2 ? "@" : src.Client.Account.Rank >= 1 ? "#" : "") + src.Name,
  28. ObjectId = src.Id,
  29. Stars = src.Stars,
  30. BubbleTime = 10,
  31. Recipient = "",
  32. Text = text.ToSafeText(),
  33. CleanText = text.ToSafeText()
  34. }, p => !p.Ignored.Contains(src.AccountId));
  35. log.InfoFormat("[{0}({1})] <{2}> {3}", src.Owner.Name, src.Owner.Id, src.Name, text);
  36. src.Owner.ChatReceived(text);
  37. }
  38.  
  39. public void SayGuild(Player src, string text)
  40. {
  41. foreach (Client i in src.Manager.Clients.Values)
  42. {
  43. if (String.Equals(src.Guild, i.Player.Guild))
  44. {
  45. i.SendPacket(new TextPacket()
  46. {
  47. Name = src.ResolveGuildChatName(),
  48. ObjectId = src.Id,
  49. Stars = src.Stars,
  50. BubbleTime = 10,
  51. Recipient = "*Guild*",
  52. Text = text.ToSafeText(),
  53. CleanText = text.ToSafeText()
  54. });
  55. }
  56. }
  57. }
  58.  
  59. public void News(string text)
  60. {
  61. foreach (var i in manager.Clients.Values)
  62. i.SendPacket(new TextPacket()
  63. {
  64. BubbleTime = 0,
  65. Stars = -1,
  66. Name = "@NEWS",
  67. Text = text.ToSafeText()
  68. });
  69. log.InfoFormat("<NEWS> {0}", text);
  70. }
  71.  
  72. public void Announce(string text)
  73. {
  74. foreach (var i in manager.Clients.Values)
  75. i.SendPacket(new TextPacket()
  76. {
  77. BubbleTime = 0,
  78. Stars = -1,
  79. Name = "@Announcement",
  80. Text = text.ToSafeText()
  81. });
  82. log.InfoFormat("<Announcement> {0}", text);
  83. }
  84.  
  85. public void Oryx(World world, string text)
  86. {
  87. world.BroadcastPacket(new TextPacket()
  88. {
  89. BubbleTime = 0,
  90. Stars = -1,
  91. Name = "#Oryx the Mad God",
  92. Text = text.ToSafeText()
  93. }, null);
  94. log.InfoFormat("[{0}({1})] <Oryx the Mad God> {2}", world.Name, world.Id, text);
  95. }
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement