Advertisement
4bdu

Untitled

Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Data;
  5. using System.Collections.Generic;
  6. using Plus.Database.Interfaces;
  7. using Plus.HabboHotel.Rooms;
  8. using Plus.HabboHotel.Users;
  9.  
  10. using Plus.Utilities;
  11. using Plus.HabboHotel.Cache;
  12.  
  13. namespace Plus.Communication.Packets.Outgoing.Moderation
  14. {
  15. class ModeratorRoomChatlogComposer : ServerPacket
  16. {
  17. public ModeratorRoomChatlogComposer(Room Room)
  18. : base(ServerPacketHeader.ModeratorRoomChatlogMessageComposer)
  19. {
  20. base.WriteByte(1);
  21. base.WriteShort(2);//Count
  22. base.WriteString("roomName");
  23. base.WriteByte(2);
  24. base.WriteString(Room.Name);
  25. base.WriteString("roomId");
  26. base.WriteByte(1);
  27. base.WriteInteger(Room.Id);
  28.  
  29. DataTable Table = null;
  30. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  31. {
  32. dbClient.SetQuery("SELECT * FROM `chatlogs` WHERE `room_id` = @rid ORDER BY `id` DESC LIMIT 250");
  33. dbClient.AddParameter("rid", Room.Id);
  34. Table = dbClient.getTable();
  35. }
  36.  
  37. base.WriteShort(Table.Rows.Count);
  38. if (Table != null)
  39. {
  40. foreach (DataRow Row in Table.Rows)
  41. {
  42. UserCache Habbo = PlusEnvironment.GetGame().GetCacheManager().GenerateUser(Convert.ToInt32(Row["user_id"]));
  43.  
  44. if (Habbo == null)
  45. {
  46. base.WriteString((((int)PlusEnvironment.GetUnixTimestamp() - Convert.ToInt32(Row["timestamp"])) * 1000).ToString());
  47. base.WriteInteger(-1);
  48. base.WriteString("Unknown User");
  49. base.WriteString(string.IsNullOrWhiteSpace(Convert.ToString(Row["message"])) ? "*user sent a blank message*" : Convert.ToString(Row["message"]));
  50. base.WriteBoolean(false);
  51. }
  52. else
  53. {
  54. base.WriteString((((int)PlusEnvironment.GetUnixTimestamp() - Convert.ToInt32(Row["timestamp"])) * 1000).ToString());
  55. base.WriteInteger(Habbo.Id);
  56. base.WriteString(Habbo.Username);
  57. base.WriteString(string.IsNullOrWhiteSpace(Convert.ToString(Row["message"]) )? "*user sent a blank message*" : Convert.ToString(Row["message"]));
  58. base.WriteBoolean(false);
  59. }
  60. }
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement