Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 50.59 KB | None | 0 0
  1. Hey, Many people have requested these and I basically released them on the git for project Plus.
  2.  
  3. So thought I'd release them here. Please bare in mind, this quickly coded & is for
  4.  
  5. PRODUCTION-201701242205-837386173.
  6.  
  7. ok, goto Groups.cs add
  8.  
  9. [CODE]public bool HasForum;[/CODE]
  10.  
  11. then add
  12.  
  13. [QUOTE]bool HasForum[/QUOTE]
  14.  
  15. to the public Group() below.
  16.  
  17. And add
  18.  
  19. [QUOTE]this.HasForum = HasForum;[/QUOTE]
  20.  
  21. inside the {}.
  22.  
  23. then inside HabboHotel->Groups Create a new folder and add these files in there.
  24.  
  25. GroupForum.cs
  26.  
  27. [CODE]using System;
  28.  
  29. using System.Collections.Generic;
  30.  
  31. using System.Data;
  32.  
  33. using System.Linq;
  34.  
  35. using Plus.Database.Interfaces;
  36.  
  37.  
  38.  
  39.  
  40.  
  41. namespace Plus.HabboHotel.Groups.Forums
  42.  
  43. {
  44.  
  45. public class GroupForum
  46.  
  47. {
  48.  
  49. public int GroupId;
  50.  
  51. public Group Group;
  52.  
  53. public GroupForumSettings Settings;
  54.  
  55. public List<GroupForumThread> Threads;
  56.  
  57.  
  58.  
  59. public int Id
  60.  
  61. {
  62.  
  63. get
  64.  
  65. {
  66.  
  67. return GroupId;
  68.  
  69. }
  70.  
  71. }
  72.  
  73.  
  74.  
  75. public string Name
  76.  
  77. {
  78.  
  79. get
  80.  
  81. {
  82.  
  83. return Group.Name;
  84.  
  85. }
  86.  
  87. }
  88.  
  89.  
  90.  
  91. public string Description
  92.  
  93. {
  94.  
  95. get
  96.  
  97. {
  98.  
  99. return Group.Description;
  100.  
  101. }
  102.  
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. public GroupForum(Group group)
  110.  
  111. {
  112.  
  113. GroupId = group.Id;
  114.  
  115. Group = group;
  116.  
  117. Settings = new GroupForumSettings(this);
  118.  
  119. Threads = new List<GroupForumThread>();
  120.  
  121.  
  122.  
  123. LoadThreads();
  124.  
  125. }
  126.  
  127.  
  128.  
  129. private void LoadThreads()
  130.  
  131. {
  132.  
  133. DataTable table;
  134.  
  135. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  136.  
  137. {
  138.  
  139. adap.SetQuery("SELECT * FROM group_forums_threads WHERE forum_id = @id ORDER BY id DESC");
  140.  
  141. adap.AddParameter("id", Id);
  142.  
  143. table = adap.getTable();
  144.  
  145. }
  146.  
  147.  
  148.  
  149. foreach (DataRow Row in table.Rows)
  150.  
  151. {
  152.  
  153. Threads.Add(new GroupForumThread(this, Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["timestamp"]), Row["caption"].ToString(), Convert.ToInt32(Row["pinned"]) == 1, Convert.ToInt32(Row["locked"]) == 1, Convert.ToInt32(Row["deleted_level"]), Convert.ToInt32(Row["deleter_user_id"])));
  154.  
  155. }
  156.  
  157. }
  158.  
  159.  
  160.  
  161. public int MessagesCount
  162.  
  163. {
  164.  
  165. get
  166.  
  167. {
  168.  
  169. return Threads.SelectMany(c => c.Posts).Count();
  170.  
  171. }
  172.  
  173. }
  174.  
  175.  
  176.  
  177. public int UnreadMessages(int userid)
  178.  
  179. {
  180.  
  181. int i = 0;
  182.  
  183. Threads.ForEach(c => i += c.GetUnreadMessages(userid));
  184.  
  185. return i;
  186.  
  187.  
  188.  
  189.  
  190.  
  191. }
  192.  
  193.  
  194.  
  195. public GroupForumThreadPost GetLastPost()
  196.  
  197. {
  198.  
  199. var Posts = Threads.SelectMany(c => c.Posts);
  200.  
  201. return Posts.OrderByDescending(c => c.Timestamp).FirstOrDefault();
  202.  
  203. }
  204.  
  205.  
  206.  
  207. public GroupForumThread GetThread(int ThreadId)
  208.  
  209. {
  210.  
  211. return Threads.FirstOrDefault(c => c.Id == ThreadId);
  212.  
  213. }
  214.  
  215.  
  216.  
  217. public GroupForumThread CreateThread(int Creator, string Caption)
  218.  
  219. {
  220.  
  221. var timestamp = (int)PlusEnvironment.GetUnixTimestamp();
  222.  
  223. var Thread = new GroupForumThread(this, 0, Creator, (int)timestamp, Caption, false, false, 0, 0);
  224.  
  225.  
  226.  
  227. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  228.  
  229. {
  230.  
  231. adap.SetQuery("INSERT INTO group_forums_threads (forum_id, user_id, caption, timestamp) VALUES (@a, @b, @c, @d)");
  232.  
  233. adap.AddParameter("a", this.Id);
  234.  
  235. adap.AddParameter("b", Creator);
  236.  
  237. adap.AddParameter("c", Caption);
  238.  
  239. adap.AddParameter("d", timestamp);
  240.  
  241. Thread.Id = (int)adap.InsertQuery();
  242.  
  243. }
  244.  
  245.  
  246.  
  247. this.Threads.Add(Thread);
  248.  
  249. return Thread;
  250.  
  251. }
  252.  
  253.  
  254.  
  255. public GroupForumThreadPost GetPost(int postid)
  256.  
  257. {
  258.  
  259. return Threads.SelectMany(c => c.Posts).Where(c => c.Id == postid).FirstOrDefault();
  260.  
  261. }
  262.  
  263. }
  264.  
  265. }
  266.  
  267. [/CODE]
  268.  
  269. GroupForumManager.cs
  270.  
  271. [CODE]using System;
  272.  
  273. using System.Collections.Generic;
  274.  
  275. using System.Linq;
  276.  
  277. using System.Text;
  278.  
  279. using System.Threading.Tasks;
  280.  
  281. using Plus.Database.Interfaces;
  282.  
  283.  
  284.  
  285.  
  286.  
  287. namespace Plus.HabboHotel.Groups.Forums
  288.  
  289. {
  290.  
  291. public class GroupForumManager
  292.  
  293. {
  294.  
  295. List<GroupForum> Forums;
  296.  
  297.  
  298.  
  299. public GroupForumManager()
  300.  
  301. {
  302.  
  303. Forums = new List<GroupForum>();
  304.  
  305.  
  306.  
  307. }
  308.  
  309.  
  310.  
  311. public GroupForum GetForum(int GroupId)
  312.  
  313. {
  314.  
  315. GroupForum f = null;
  316.  
  317. return TryGetForum(GroupId, out f) ? f : null;
  318.  
  319. }
  320.  
  321.  
  322.  
  323. public GroupForum CreateGroupForum(Group Gp)
  324.  
  325. {
  326.  
  327. GroupForum GF;
  328.  
  329. if (TryGetForum(Gp.Id, out GF))
  330.  
  331. return GF;
  332.  
  333.  
  334.  
  335. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  336.  
  337. {
  338.  
  339. adap.SetQuery("INSERT INTO group_forums_settings (group_id) VALUES (@gp)");
  340.  
  341. adap.AddParameter("gp", Gp.Id);
  342.  
  343. adap.RunQuery();
  344.  
  345.  
  346.  
  347. adap.SetQuery("UPDATE groups SET has_forum = '1' WHERE id = @id");
  348.  
  349. adap.AddParameter("id", Gp.Id);
  350.  
  351. adap.RunQuery();
  352.  
  353. }
  354.  
  355.  
  356.  
  357. GF = new GroupForum(Gp);
  358.  
  359. Forums.Add(GF);
  360.  
  361. return GF;
  362.  
  363. }
  364.  
  365.  
  366.  
  367. public bool TryGetForum(int Id, out GroupForum Forum)
  368.  
  369. {
  370.  
  371. if ((Forum = Forums.FirstOrDefault(c => c.Id == Id)) != null)
  372.  
  373. return true;
  374.  
  375.  
  376.  
  377. Group Gp;
  378.  
  379. if (!PlusEnvironment.GetGame().GetGroupManager().TryGetGroup(Id, out Gp))
  380.  
  381. return false;
  382.  
  383.  
  384.  
  385. if (!Gp.HasForum)
  386.  
  387. return false;
  388.  
  389.  
  390.  
  391. Forum = new GroupForum(Gp);
  392.  
  393. Forums.Add(Forum);
  394.  
  395. return true;
  396.  
  397. }
  398.  
  399.  
  400.  
  401. public List<GroupForum> GetForumsByUserId(int Userid)
  402.  
  403. {
  404.  
  405. GroupForum F;
  406.  
  407. return PlusEnvironment.GetGame().GetGroupManager().GetGroupsForUser(Userid).Where(c => TryGetForum(c.Id, out F)).Select(c => GetForum(c.Id)).ToList();
  408.  
  409. }
  410.  
  411. }
  412.  
  413. }
  414.  
  415. [/CODE]
  416.  
  417. GroupForumSettings.cs
  418.  
  419. [CODE]using Plus.HabboHotel.GameClients;
  420.  
  421. using System;
  422.  
  423. using System.Collections.Generic;
  424.  
  425. using System.Linq;
  426.  
  427. using System.Text;
  428.  
  429. using Plus.Database.Interfaces;
  430.  
  431. using System.Data;
  432.  
  433. using System.Threading.Tasks;
  434.  
  435.  
  436.  
  437. namespace Plus.HabboHotel.Groups.Forums
  438.  
  439.  
  440.  
  441. {
  442.  
  443. public class GroupForumSettings {
  444.  
  445.  
  446.  
  447. public GroupForum ParentForum { get; private set; }
  448.  
  449.  
  450.  
  451. public int WhoCanRead;
  452.  
  453. public int WhoCanPost;
  454.  
  455. public int WhoCanInitDiscussions;
  456.  
  457. public int WhoCanModerate;
  458.  
  459.  
  460.  
  461. public GroupForumSettings(GroupForum Forum)
  462.  
  463. {
  464.  
  465. this.ParentForum = Forum;
  466.  
  467.  
  468.  
  469. DataRow Row;
  470.  
  471. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  472.  
  473. {
  474.  
  475. adap.SetQuery("SELECT * FROM group_forums_settings WHERE group_id = '" + Forum.Id + "'");
  476.  
  477. //adap.AddParameter("id", Forum.Id);
  478.  
  479. Row = adap.getRow();
  480.  
  481. }
  482.  
  483.  
  484.  
  485. if (Row == null)
  486.  
  487. {
  488.  
  489. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  490.  
  491. {
  492.  
  493. adap.SetQuery("REPLACE INTO group_forums_settings (group_id) VALUES @id);SELECT * FROM group_forums_settings WHERE group_id = @id");
  494.  
  495. adap.AddParameter("id", Forum.Id);
  496.  
  497. Row = adap.getRow();
  498.  
  499. }
  500.  
  501. }
  502.  
  503.  
  504.  
  505. this.WhoCanRead = Convert.ToInt32(Row["who_can_read"]);
  506.  
  507. this.WhoCanPost = Convert.ToInt32(Row["who_can_post"]);
  508.  
  509. this.WhoCanInitDiscussions = Convert.ToInt32(Row["who_can_init_discussions"]);
  510.  
  511. this.WhoCanModerate = Convert.ToInt32(Row["who_can_mod"]);
  512.  
  513. }
  514.  
  515.  
  516.  
  517. public void Save()
  518.  
  519. {
  520.  
  521. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  522.  
  523. {
  524.  
  525. adap.SetQuery("UPDATE group_forums_settings SET who_can_read = @a, who_can_post = @b, who_can_init_discussions = @c, who_can_mod = @d WHERE group_id = @id");
  526.  
  527. adap.AddParameter("id", ParentForum.Id);
  528.  
  529. adap.AddParameter("a", WhoCanRead);
  530.  
  531. adap.AddParameter("b", WhoCanPost);
  532.  
  533. adap.AddParameter("c", WhoCanInitDiscussions);
  534.  
  535. adap.AddParameter("d", WhoCanModerate);
  536.  
  537. adap.RunQuery();
  538.  
  539. }
  540.  
  541. }
  542.  
  543.  
  544.  
  545. public GroupForumPermissionLevel GetLevel(int n)
  546.  
  547. {
  548.  
  549. switch (n)
  550.  
  551. {
  552.  
  553. case 0:
  554.  
  555. default:
  556.  
  557. return GroupForumPermissionLevel.ANYONE;
  558.  
  559.  
  560.  
  561. case 1:
  562.  
  563. return GroupForumPermissionLevel.JUST_MEMBERS;
  564.  
  565.  
  566.  
  567. case 2:
  568.  
  569. return GroupForumPermissionLevel.JUST_ADMIN;
  570.  
  571.  
  572.  
  573. case 3:
  574.  
  575. return GroupForumPermissionLevel.JUST_OWNER;
  576.  
  577. }
  578.  
  579. }
  580.  
  581.  
  582.  
  583. public string GetReasonForNot(GameClient Session, int PermissionType)
  584.  
  585. {
  586.  
  587. if (Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
  588.  
  589. return "";
  590.  
  591.  
  592.  
  593. switch (GetLevel(PermissionType))
  594.  
  595. {
  596.  
  597. default:
  598.  
  599. case GroupForumPermissionLevel.ANYONE:
  600.  
  601. return "";
  602.  
  603.  
  604.  
  605. case GroupForumPermissionLevel.JUST_ADMIN:
  606.  
  607. return ParentForum.Group.IsAdmin(Session.GetHabbo().Id) ? "" : "not_admin";
  608.  
  609.  
  610.  
  611. case GroupForumPermissionLevel.JUST_MEMBERS:
  612.  
  613. return ParentForum.Group.IsMember(Session.GetHabbo().Id) ? "" : "not_member";
  614.  
  615.  
  616.  
  617. case GroupForumPermissionLevel.JUST_OWNER:
  618.  
  619. return ParentForum.Group.CreatorId == Session.GetHabbo().Id ? "" : "not_owner";
  620.  
  621. }
  622.  
  623. }
  624.  
  625. }
  626.  
  627.  
  628.  
  629. public enum GroupForumPermissionLevel
  630.  
  631. {
  632.  
  633. ANYONE,
  634.  
  635. JUST_MEMBERS,
  636.  
  637. JUST_ADMIN,
  638.  
  639. JUST_OWNER
  640.  
  641. }
  642.  
  643.  
  644.  
  645.  
  646.  
  647. }
  648.  
  649. [/CODE]
  650.  
  651. GroupForumThread.cs
  652.  
  653. [CODE]using Plus.Communication.Packets.Outgoing;
  654.  
  655. using Plus.HabboHotel.GameClients;
  656.  
  657. using Plus.HabboHotel.Users;
  658.  
  659. using System;
  660.  
  661. using System.Collections.Generic;
  662.  
  663. using System.Data;
  664.  
  665. using System.Linq;
  666.  
  667. using Plus.Database.Interfaces;
  668.  
  669.  
  670.  
  671. using System.Text;
  672.  
  673. namespace Plus.HabboHotel.Groups.Forums
  674.  
  675. {
  676.  
  677. public class GroupForumThread
  678.  
  679. {
  680.  
  681. public int Id;
  682.  
  683. public int UserId;
  684.  
  685. public string Caption;
  686.  
  687. public int Timestamp;
  688.  
  689. public bool Pinned;
  690.  
  691. public bool Locked;
  692.  
  693. public int DeletedLevel;
  694.  
  695. public int DeleterUserId;
  696.  
  697. public int DeletedTimestamp;
  698.  
  699.  
  700.  
  701. public GroupForum ParentForum;
  702.  
  703. public List<GroupForumThreadPost> Posts;
  704.  
  705.  
  706.  
  707. public List<GameClient> UsersOnThread;
  708.  
  709. public List<GroupForumThreadPostView> Views;
  710.  
  711.  
  712.  
  713.  
  714.  
  715. public GroupForumThread(GroupForum parent, int id, int userid, int timestamp, string caption, bool pinned, bool locked, int deletedlevel, int deleterid)
  716.  
  717. {
  718.  
  719.  
  720.  
  721. Views = new List<GroupForumThreadPostView>(); ;
  722.  
  723. UsersOnThread = new List<GameClient>();
  724.  
  725. ParentForum = parent;
  726.  
  727.  
  728.  
  729. Id = id;
  730.  
  731. UserId = userid;
  732.  
  733. Timestamp = timestamp;
  734.  
  735. Caption = caption;
  736.  
  737. Posts = new List<GroupForumThreadPost>();
  738.  
  739.  
  740.  
  741. Pinned = pinned;
  742.  
  743. Locked = locked;
  744.  
  745. DeletedLevel = deletedlevel;
  746.  
  747. DeleterUserId = deleterid;
  748.  
  749. DeletedTimestamp = (int)PlusEnvironment.GetUnixTimestamp();
  750.  
  751.  
  752.  
  753. DataTable table;
  754.  
  755. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  756.  
  757. {
  758.  
  759. adap.SetQuery("SELECT * FROM group_forums_thread_posts WHERE thread_id = @id ORDER BY `timestamp`");
  760.  
  761. adap.AddParameter("id", this.Id);
  762.  
  763. table = adap.getTable();
  764.  
  765. }
  766.  
  767.  
  768.  
  769. foreach (DataRow Row in table.Rows)
  770.  
  771. {
  772.  
  773. Posts.Add(new GroupForumThreadPost(this, Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["timestamp"]), Row["message"].ToString(), Convert.ToInt32(Row["deleted_level"]), Convert.ToInt32(Row["deleter_user_id"])));
  774.  
  775. }
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783. using (IQueryAdapter Adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  784.  
  785. {
  786.  
  787. Adap.SetQuery("SELECT * FROM group_forums_thread_views WHERE thread_id = @id");
  788.  
  789. Adap.AddParameter("id", Id);
  790.  
  791. table = Adap.getTable();
  792.  
  793. }
  794.  
  795.  
  796.  
  797.  
  798.  
  799. foreach (DataRow Row in table.Rows)
  800.  
  801. {
  802.  
  803. Views.Add(new GroupForumThreadPostView(Convert.ToInt32(Row["id"]), Convert.ToInt32(Row["user_id"]), Convert.ToInt32(Row["count"])));
  804.  
  805. }
  806.  
  807.  
  808.  
  809. }
  810.  
  811.  
  812.  
  813. private void GroupForumThread_OnClientDisconnect(GameClient client)
  814.  
  815. {
  816.  
  817. if (UsersOnThread.Contains(client))
  818.  
  819. UsersOnThread.Remove(client);
  820.  
  821. }
  822.  
  823.  
  824.  
  825.  
  826.  
  827. public void AddView(int userid, int count = -1)
  828.  
  829. {
  830.  
  831. GroupForumThreadPostView v;
  832.  
  833. if ((v = GetView(userid)) != null)
  834.  
  835. {
  836.  
  837. v.Count = count >= 0 ? count : Posts.Count;
  838.  
  839. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  840.  
  841. {
  842.  
  843. adap.SetQuery("UPDATE group_forums_thread_views SET count = @c WHERE thread_id = @p AND user_id = @u");
  844.  
  845. adap.AddParameter("c", v.Count);
  846.  
  847. adap.AddParameter("p", this.Id);
  848.  
  849. adap.AddParameter("u", userid);
  850.  
  851. adap.RunQuery();
  852.  
  853. }
  854.  
  855. }
  856.  
  857. else
  858.  
  859. {
  860.  
  861. v = new GroupForumThreadPostView(0, userid, Posts.Count);
  862.  
  863. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  864.  
  865. {
  866.  
  867. adap.SetQuery("INSERT INTO group_forums_thread_views (thread_id, user_id, count) VALUES (@t, @u, @c)");
  868.  
  869. adap.AddParameter("t", this.Id);
  870.  
  871. adap.AddParameter("u", userid);
  872.  
  873. adap.AddParameter("c", v.Count);
  874.  
  875. v.Id = (int)adap.InsertQuery();
  876.  
  877. Views.Add(v);
  878.  
  879. }
  880.  
  881. }
  882.  
  883. }
  884.  
  885.  
  886.  
  887. public GroupForumThreadPostView GetView(int userid)
  888.  
  889. {
  890.  
  891. return Views.FirstOrDefault(c => c.UserId == userid);
  892.  
  893. }
  894.  
  895.  
  896.  
  897. public int GetUnreadMessages(int userid)
  898.  
  899. {
  900.  
  901. GroupForumThreadPostView v;
  902.  
  903. return (v = GetView(userid)) != null ? Posts.Count - v.Count : Posts.Count;
  904.  
  905. }
  906.  
  907.  
  908.  
  909. public List<GroupForumThreadPost> GetUserPosts(int userid)
  910.  
  911. {
  912.  
  913. return Posts.Where(c => c.UserId == userid).ToList();
  914.  
  915. }
  916.  
  917.  
  918.  
  919. public Habbo GetAuthor()
  920.  
  921. {
  922.  
  923. return PlusEnvironment.GetHabboById(UserId);
  924.  
  925. }
  926.  
  927.  
  928.  
  929. public Habbo GetDeleter()
  930.  
  931. {
  932.  
  933. return PlusEnvironment.GetHabboById(DeleterUserId);
  934.  
  935. }
  936.  
  937.  
  938.  
  939. public GroupForumThreadPost CreatePost(int userid, string message)
  940.  
  941. {
  942.  
  943. var now = (int)PlusEnvironment.GetUnixTimestamp();
  944.  
  945. var Post = new GroupForumThreadPost(this, 0, userid, now, message, 0, 0);
  946.  
  947.  
  948.  
  949. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  950.  
  951. {
  952.  
  953. adap.SetQuery("INSERT INTO group_forums_thread_posts (thread_id, user_id, message, timestamp) VALUES (@a, @b, @c, @d)");
  954.  
  955. adap.AddParameter("a", this.Id);
  956.  
  957. adap.AddParameter("b", userid);
  958.  
  959. adap.AddParameter("c", message);
  960.  
  961. adap.AddParameter("d", now);
  962.  
  963. Post.Id = (int)adap.InsertQuery();
  964.  
  965. }
  966.  
  967.  
  968.  
  969. Posts.Add(Post);
  970.  
  971. return Post;
  972.  
  973.  
  974.  
  975. }
  976.  
  977.  
  978.  
  979. public void AddClientToThread(GameClient Session)
  980.  
  981. {
  982.  
  983. UsersOnThread.Add(Session);
  984.  
  985. }
  986.  
  987.  
  988.  
  989. public void RemoveClientFromThread(GameClient Session)
  990.  
  991. {
  992.  
  993. if (UsersOnThread.Contains(Session))
  994.  
  995. UsersOnThread.Add(Session);
  996.  
  997. }
  998.  
  999.  
  1000.  
  1001. public GroupForumThreadPost GetLastMessage()
  1002.  
  1003. {
  1004.  
  1005. return Posts.LastOrDefault();
  1006.  
  1007. }
  1008.  
  1009.  
  1010.  
  1011. public void SerializeData(GameClient Session, ServerPacket Packet)
  1012.  
  1013. {
  1014.  
  1015. var lastpost = GetLastMessage();
  1016.  
  1017. var isn = lastpost == null;
  1018.  
  1019. Packet.WriteInteger(Id);
  1020.  
  1021. Packet.WriteInteger(GetAuthor().Id);
  1022.  
  1023. Packet.WriteString(GetAuthor().Username);
  1024.  
  1025. Packet.WriteString(Caption);
  1026.  
  1027. Packet.WriteBoolean(Pinned);
  1028.  
  1029. Packet.WriteBoolean(Locked);
  1030.  
  1031. Packet.WriteInteger((int)(PlusEnvironment.GetUnixTimestamp() - Timestamp));
  1032.  
  1033. Packet.WriteInteger(Posts.Count);
  1034.  
  1035. Packet.WriteInteger(GetUnreadMessages(Session.GetHabbo().Id));
  1036.  
  1037. Packet.WriteInteger(0);
  1038.  
  1039.  
  1040.  
  1041. Packet.WriteInteger(!isn ? lastpost.GetAuthor().Id : 0);
  1042.  
  1043. Packet.WriteString(!isn ? lastpost.GetAuthor().Username : "");
  1044.  
  1045. Packet.WriteInteger(!isn ? (int)(PlusEnvironment.GetUnixTimestamp() - lastpost.Timestamp) : 0);
  1046.  
  1047.  
  1048.  
  1049. Packet.WriteByte(DeletedLevel * 10);
  1050.  
  1051.  
  1052.  
  1053. var deleter = GetDeleter();
  1054.  
  1055. if (deleter != null)
  1056.  
  1057. {
  1058.  
  1059. Packet.WriteInteger(deleter.Id);
  1060.  
  1061. Packet.WriteString(deleter.Username);
  1062.  
  1063. Packet.WriteInteger((int)(PlusEnvironment.GetUnixTimestamp() - DeletedTimestamp));
  1064.  
  1065. }
  1066.  
  1067. else
  1068.  
  1069. {
  1070.  
  1071. Packet.WriteInteger(1);
  1072.  
  1073. Packet.WriteString("unknow");
  1074.  
  1075. Packet.WriteInteger(0);
  1076.  
  1077. }
  1078.  
  1079. }
  1080.  
  1081.  
  1082.  
  1083. public GroupForumThreadPost GetPost(int postId)
  1084.  
  1085. {
  1086.  
  1087. return Posts.FirstOrDefault(c => c.Id == postId);
  1088.  
  1089. }
  1090.  
  1091.  
  1092.  
  1093. public void Log(int threadId, int userID, string type)
  1094.  
  1095. {
  1096.  
  1097. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1098.  
  1099. {
  1100.  
  1101. adap.SetQuery("INSERT INTO group_forums_logs (thread_id, user_id, type) VALUES (@a, @duid, @type)");
  1102.  
  1103. adap.AddParameter("type", type);
  1104.  
  1105. adap.AddParameter("a", threadId);
  1106.  
  1107. adap.AddParameter("duid", DeleterUserId);
  1108.  
  1109. adap.RunQuery();
  1110.  
  1111. }
  1112.  
  1113. }
  1114.  
  1115. public void Save()
  1116.  
  1117. {
  1118.  
  1119. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1120.  
  1121. {
  1122.  
  1123. adap.SetQuery("UPDATE group_forums_threads SET pinned = '@pinned', locked ='@locked', deleted_level = @dl, deleter_user_id = @duid WHERE id = @id");
  1124.  
  1125. adap.AddParameter("pinned", Pinned ? 1 : 0);
  1126.  
  1127. adap.AddParameter("locked", Locked ? 1 : 0);
  1128.  
  1129. adap.AddParameter("dl", DeletedLevel);
  1130.  
  1131. adap.AddParameter("duid", DeleterUserId);
  1132.  
  1133. adap.AddParameter("id", Id);
  1134.  
  1135. adap.RunQuery();
  1136.  
  1137. }
  1138.  
  1139. }
  1140.  
  1141. }
  1142.  
  1143. }
  1144.  
  1145.  
  1146.  
  1147. [/CODE]
  1148.  
  1149.  
  1150.  
  1151. GroupForumThreadPost.cs
  1152.  
  1153. [CODE]using Plus.Communication.Packets.Outgoing;
  1154.  
  1155. using Plus.HabboHotel.Users;
  1156.  
  1157. using System;
  1158.  
  1159. using System.Collections.Generic;
  1160.  
  1161. using System.Data;
  1162.  
  1163. using System.Linq;
  1164.  
  1165. using Plus.Database.Interfaces;
  1166.  
  1167.  
  1168.  
  1169. using System.Text;
  1170.  
  1171. using System.Threading.Tasks;
  1172.  
  1173. using Plus.HabboHotel.GameClients;
  1174.  
  1175.  
  1176.  
  1177. namespace Plus.HabboHotel.Groups.Forums
  1178.  
  1179. {
  1180.  
  1181. public class GroupForumThreadPost
  1182.  
  1183. {
  1184.  
  1185. public int Id;
  1186.  
  1187. public int UserId;
  1188.  
  1189. public int Timestamp;
  1190.  
  1191. public string Message;
  1192.  
  1193.  
  1194.  
  1195. public int DeleterId;
  1196.  
  1197. public int DeletedLevel;
  1198.  
  1199.  
  1200.  
  1201. public GroupForumThread ParentThread;
  1202.  
  1203. public GroupForumThreadPost(GroupForumThread parent, int id, int userid, int timestamp, string message, int deletedlevel, int deleterid)
  1204.  
  1205. {
  1206.  
  1207.  
  1208.  
  1209. ParentThread = parent;
  1210.  
  1211. Id = id;
  1212.  
  1213. UserId = userid;
  1214.  
  1215. Timestamp = timestamp;
  1216.  
  1217. Message = message;
  1218.  
  1219.  
  1220.  
  1221. DeleterId = deleterid;
  1222.  
  1223. DeletedLevel = deletedlevel;
  1224.  
  1225.  
  1226.  
  1227. }
  1228.  
  1229.  
  1230.  
  1231. public Habbo GetDeleter()
  1232.  
  1233. {
  1234.  
  1235. return PlusEnvironment.GetHabboById(DeleterId);
  1236.  
  1237. }
  1238.  
  1239.  
  1240.  
  1241. public Habbo GetAuthor()
  1242.  
  1243. {
  1244.  
  1245. return PlusEnvironment.GetHabboById(UserId);
  1246.  
  1247. }
  1248.  
  1249.  
  1250.  
  1251. public void SerializeData(GameClient Session, ServerPacket Packet)
  1252.  
  1253. {
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259. var User = GetAuthor();
  1260.  
  1261. var oculterData = GetDeleter();
  1262.  
  1263. Packet.WriteInteger(Id);
  1264.  
  1265. Packet.WriteInteger(ParentThread.Posts.IndexOf(this));
  1266.  
  1267.  
  1268.  
  1269. Packet.WriteInteger(User.Id);
  1270.  
  1271. Packet.WriteString(User.Username);
  1272.  
  1273. Packet.WriteString(User.Look);
  1274.  
  1275.  
  1276.  
  1277. Packet.WriteInteger((int)(PlusEnvironment.GetUnixTimestamp() - Timestamp));
  1278.  
  1279. Packet.WriteString(Message.Replace("{username}", Session.GetHabbo().Username));
  1280.  
  1281. Packet.WriteByte(DeletedLevel * 10);
  1282.  
  1283. Packet.WriteInteger(oculterData != null ? oculterData.Id : 0);
  1284.  
  1285. Packet.WriteString(oculterData != null ? oculterData.Username : "Unknown");
  1286.  
  1287. Packet.WriteInteger(242342340);
  1288.  
  1289. Packet.WriteInteger(ParentThread.GetUserPosts(User.Id).Count);
  1290.  
  1291. }
  1292.  
  1293. public void Log(int postID, int userID, string type)
  1294.  
  1295. {
  1296.  
  1297. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1298.  
  1299. {
  1300.  
  1301. adap.SetQuery("INSERT INTO group_forums_logs (thread_id, user_id, type) VALUES (@a, @duid, @type)");
  1302.  
  1303. adap.AddParameter("type", type);
  1304.  
  1305. adap.AddParameter("a", postID);
  1306.  
  1307. adap.AddParameter("duid", userID);
  1308.  
  1309. adap.RunQuery();
  1310.  
  1311. }
  1312.  
  1313. }
  1314.  
  1315. internal void Save()
  1316.  
  1317. {
  1318.  
  1319. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1320.  
  1321. {
  1322.  
  1323. adap.SetQuery("UPDATE group_forums_thread_views SET deleted_level = @dl, deleter_user_id = @duid WHERE id = @id");
  1324.  
  1325. adap.AddParameter("dl", DeletedLevel);
  1326.  
  1327. adap.AddParameter("duid", DeleterId);
  1328.  
  1329. adap.AddParameter("id", Id);
  1330.  
  1331. adap.RunQuery();
  1332.  
  1333. }
  1334.  
  1335. }
  1336.  
  1337. }
  1338.  
  1339. }
  1340.  
  1341. [/CODE]
  1342.  
  1343.  
  1344.  
  1345. GroupForumThreadPostView.cs
  1346.  
  1347. [CODE]using System;
  1348.  
  1349. using System.Collections.Generic;
  1350.  
  1351. using System.Linq;
  1352.  
  1353. using System.Text;
  1354.  
  1355.  
  1356.  
  1357. namespace Plus.HabboHotel.Groups.Forums
  1358.  
  1359. {
  1360.  
  1361. public class GroupForumThreadPostView
  1362.  
  1363. {
  1364.  
  1365. public int Id;
  1366.  
  1367. public int UserId;
  1368.  
  1369. public int Count;
  1370.  
  1371.  
  1372.  
  1373. public GroupForumThreadPostView(int id, int userid, int count)
  1374.  
  1375. {
  1376.  
  1377. Id = id;
  1378.  
  1379. UserId = userid;
  1380.  
  1381. Count = count;
  1382.  
  1383. }
  1384.  
  1385. }
  1386.  
  1387. }[/CODE]
  1388.  
  1389.  
  1390.  
  1391. ok, now for the rest.
  1392.  
  1393.  
  1394.  
  1395. Goto PacketManager then add this.RegisterGroupForums(); then this
  1396.  
  1397. [CODE]private void RegisterGroupForums()
  1398.  
  1399. {
  1400.  
  1401. this._incomingPackets.Add(ClientPacketHeader.GetForumsListDataMessageEvent, new GetForumsListDataEvent());
  1402.  
  1403. this._incomingPackets.Add(ClientPacketHeader.GetForumStatsMessageEvent, new GetForumStatsEvent());
  1404.  
  1405. this._incomingPackets.Add(ClientPacketHeader.GetThreadsListDataMessageEvent, new GetThreadsListDataEvent());
  1406.  
  1407. this._incomingPackets.Add(ClientPacketHeader.GetThreadDataMessageEvent, new GetThreadDataEvent());
  1408.  
  1409. this._incomingPackets.Add(ClientPacketHeader.PostGroupContentMessageEvent, new PostGroupContentEvent());
  1410.  
  1411. this._incomingPackets.Add(ClientPacketHeader.DeleteGroupThreadMessageEvent, new DeleteGroupThreadEvent());
  1412.  
  1413. this._incomingPackets.Add(ClientPacketHeader.UpdateForumReadMarkerMessageEvent, new UpdateForumReadMarkerEvent());
  1414.  
  1415. this._incomingPackets.Add(ClientPacketHeader.UpdateForumSettingsMessageEvent, new UpdateForumSettingsEvent());
  1416.  
  1417. this._incomingPackets.Add(ClientPacketHeader.UpdateForumThreadStatusMessageEvent, new UpdateForumThreadStatusEvent());
  1418.  
  1419. this._incomingPackets.Add(ClientPacketHeader.DeleteGroupPostMessageEvent, new DeleteGroupPostEvent());
  1420.  
  1421. }[/CODE]
  1422.  
  1423.  
  1424.  
  1425. Ok, in COmmunication->Packets->incoming->Groups
  1426.  
  1427. Add these files.
  1428.  
  1429.  
  1430.  
  1431. GetForumsListDataEvent.cs
  1432.  
  1433. [CODE]using Plus.Communication.Packets.Outgoing;
  1434.  
  1435. using Plus.Communication.Packets.Outgoing.Groups;
  1436.  
  1437. using Plus.HabboHotel.GameClients;
  1438.  
  1439. using Plus.HabboHotel.Groups.Forums;
  1440.  
  1441. using System;
  1442.  
  1443.  
  1444.  
  1445. using Plus.Database.Interfaces;
  1446.  
  1447. using System.Collections.Generic;
  1448.  
  1449. using System.Data;
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455. namespace Plus.Communication.Packets.Incoming.Groups
  1456.  
  1457. {
  1458.  
  1459. class GetForumsListDataEvent : IPacketEvent
  1460.  
  1461. {
  1462.  
  1463. public void Parse(GameClient Session, ClientPacket Packet)
  1464.  
  1465. {
  1466.  
  1467. var int1 = Packet.PopInt();
  1468.  
  1469. var int2 = Packet.PopInt();
  1470.  
  1471. int int3 = Packet.PopInt();
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479. var forums = new List<GroupForum>();
  1480.  
  1481. DataTable table;
  1482.  
  1483.  
  1484.  
  1485. switch (int1)
  1486.  
  1487. {
  1488.  
  1489. case 2:
  1490.  
  1491. var Forums = PlusEnvironment.GetGame().GetGroupForumManager().GetForumsByUserId(Session.GetHabbo().Id);
  1492.  
  1493.  
  1494.  
  1495. if (Forums.Count - 1 >= int2)
  1496.  
  1497. {
  1498.  
  1499. Forums = Forums.GetRange(int2, Math.Min(int3, Forums.Count));
  1500.  
  1501. }
  1502.  
  1503. Session.SendMessage(new ForumsListDataComposer(Forums, Session, int1, int2, int3));
  1504.  
  1505. return;
  1506.  
  1507.  
  1508.  
  1509. case 0:
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1516.  
  1517. {
  1518.  
  1519. adap.SetQuery("SELECT g.id FROM groups as g INNER JOIN group_forums_thread_posts as posts, group_forums_threads as threads WHERE posts.thread_id = threads.id AND @now - posts.`timestamp`<= @Sdays AND threads.forum_id = g.id GROUP BY g.id ORDER BY posts.`timestamp` DESC LIMIT @Index, @LiMiT");
  1520.  
  1521. adap.AddParameter("limit", int3);
  1522.  
  1523. adap.AddParameter("index", int2);
  1524.  
  1525. adap.AddParameter("now", (int)PlusEnvironment.GetUnixTimestamp());
  1526.  
  1527. adap.AddParameter("sdays", (60 * 60 * 24 * 7));
  1528.  
  1529. table = adap.getTable();
  1530.  
  1531. }
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539. foreach (DataRow Row in table.Rows)
  1540.  
  1541. {
  1542.  
  1543. GroupForum forum;
  1544.  
  1545. if (PlusEnvironment.GetGame().GetGroupForumManager().TryGetForum(Convert.ToInt32(Row["id"]), out forum))
  1546.  
  1547. forums.Add(forum);
  1548.  
  1549. }
  1550.  
  1551. break;
  1552.  
  1553.  
  1554.  
  1555. case 1:
  1556.  
  1557. using (IQueryAdapter adap = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  1558.  
  1559. {
  1560.  
  1561. adap.SetQuery("SELECT g.id FROM groups as g INNER JOIN group_forums_thread_views as v, group_forums_threads as threads WHERE v.thread_id = threads.id AND threads.forum_id = g.id AND @now - v.`timestamp` <= @Sdays GROUP BY g.id ORDER BY v.`timestamp` DESC LIMIT @Index, @LiMiT");
  1562.  
  1563. adap.AddParameter("limit", int3);
  1564.  
  1565. adap.AddParameter("index", int2);
  1566.  
  1567. adap.AddParameter("now", (int)PlusEnvironment.GetUnixTimestamp());
  1568.  
  1569. adap.AddParameter("sdays", (60 * 60 * 24 * 7));
  1570.  
  1571.  
  1572.  
  1573. table = adap.getTable();
  1574.  
  1575. }
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583. foreach (DataRow Row in table.Rows)
  1584.  
  1585. {
  1586.  
  1587. GroupForum forum;
  1588.  
  1589. if (PlusEnvironment.GetGame().GetGroupForumManager().TryGetForum(Convert.ToInt32(Row["id"]), out forum))
  1590.  
  1591. forums.Add(forum);
  1592.  
  1593. }
  1594.  
  1595. break;
  1596.  
  1597. }
  1598.  
  1599.  
  1600.  
  1601. Session.SendMessage(new ForumsListDataComposer(forums, Session, int1, int2, int3));
  1602.  
  1603.  
  1604.  
  1605. }
  1606.  
  1607. }
  1608.  
  1609. }
  1610.  
  1611. [/CODE]
  1612.  
  1613. GetForumStatsEvent.cs
  1614.  
  1615. [CODE]using Plus.Communication.Packets.Outgoing;
  1616.  
  1617. using Plus.Communication.Packets.Outgoing.Groups;
  1618.  
  1619. using Plus.HabboHotel.GameClients;
  1620.  
  1621. using Plus.HabboHotel.Groups.Forums;
  1622.  
  1623. using System;
  1624.  
  1625. using System.Collections.Generic;
  1626.  
  1627. using System.Linq;
  1628.  
  1629. using System.Text;
  1630.  
  1631. using System.Threading.Tasks;
  1632.  
  1633.  
  1634.  
  1635. namespace Plus.Communication.Packets.Incoming.Groups
  1636.  
  1637. {
  1638.  
  1639. class GetForumStatsEvent : IPacketEvent
  1640.  
  1641. {
  1642.  
  1643. public void Parse(GameClient Session, ClientPacket Packet)
  1644.  
  1645. {
  1646.  
  1647. var GroupForumId = Packet.PopInt();
  1648.  
  1649.  
  1650.  
  1651. GroupForum Forum;
  1652.  
  1653. if (!PlusEnvironment.GetGame().GetGroupForumManager().TryGetForum(GroupForumId, out Forum))
  1654.  
  1655. {
  1656.  
  1657. Session.SendNotification("Oops, There was a problem. Contact Staff to resolve this.");
  1658.  
  1659. return;
  1660.  
  1661. }
  1662.  
  1663.  
  1664.  
  1665. Session.SendMessage(new ForumDataComposer(Forum, Session));
  1666.  
  1667.  
  1668.  
  1669. }
  1670.  
  1671. }
  1672.  
  1673. }
  1674.  
  1675. [/CODE]
  1676.  
  1677. GetThreadDataEvent.cs
  1678.  
  1679. [CODE]
  1680.  
  1681. using Plus.Communication.Packets.Outgoing.Groups;
  1682.  
  1683. using Plus.HabboHotel.GameClients;
  1684.  
  1685. using System;
  1686.  
  1687. using System.Collections.Generic;
  1688.  
  1689. using System.Linq;
  1690.  
  1691. using System.Text;
  1692.  
  1693. using System.Threading.Tasks;
  1694.  
  1695.  
  1696.  
  1697. namespace Plus.Communication.Packets.Incoming.Groups
  1698.  
  1699. {
  1700.  
  1701. class GetThreadDataEvent : IPacketEvent
  1702.  
  1703. {
  1704.  
  1705. public void Parse(GameClient Session, ClientPacket Packet)
  1706.  
  1707. {
  1708.  
  1709. var ForumId = Packet.PopInt();
  1710.  
  1711. var ThreadId = Packet.PopInt();
  1712.  
  1713. var StartIndex = Packet.PopInt();
  1714.  
  1715. var length = Packet.PopInt();
  1716.  
  1717.  
  1718.  
  1719. var Forum = PlusEnvironment.GetGame().GetGroupForumManager().GetForum(ForumId);
  1720.  
  1721.  
  1722.  
  1723. if (Forum == null)
  1724.  
  1725. {
  1726.  
  1727.  
  1728.  
  1729. return;
  1730.  
  1731. }
  1732.  
  1733.  
  1734.  
  1735. var Thread = Forum.GetThread(ThreadId);
  1736.  
  1737. if (Thread == null)
  1738.  
  1739. {
  1740.  
  1741.  
  1742.  
  1743. return;
  1744.  
  1745. }
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751. Session.SendMessage(new ThreadDataComposer(Session, Thread, StartIndex, length));
  1752.  
  1753.  
  1754.  
  1755. }
  1756.  
  1757. }
  1758.  
  1759. }
  1760.  
  1761. [/CODE]
  1762.  
  1763. GetThreadListDataEvent.cs
  1764.  
  1765. [CODE]using Plus.Communication.Packets.Outgoing;
  1766.  
  1767. using Plus.Communication.Packets.Outgoing.Groups;
  1768.  
  1769. using Plus.HabboHotel.GameClients;
  1770.  
  1771. using System;
  1772.  
  1773. using System.Collections.Generic;
  1774.  
  1775. using System.Linq;
  1776.  
  1777. using System.Text;
  1778.  
  1779. using System.Threading.Tasks;
  1780.  
  1781. using Plus.HabboHotel.Groups.Forums;
  1782.  
  1783.  
  1784.  
  1785. namespace Plus.Communication.Packets.Incoming.Groups
  1786.  
  1787. {
  1788.  
  1789. class GetThreadsListDataEvent : IPacketEvent
  1790.  
  1791. {
  1792.  
  1793. public void Parse(GameClient Session, ClientPacket Packet)
  1794.  
  1795. {
  1796.  
  1797. var ForumId = Packet.PopInt();
  1798.  
  1799. var Int2 = Packet.PopInt();
  1800.  
  1801. var Int3 = Packet.PopInt();
  1802.  
  1803.  
  1804.  
  1805. var Forum = PlusEnvironment.GetGame().GetGroupForumManager().GetForum(ForumId);
  1806.  
  1807. if (Forum == null)
  1808.  
  1809. {
  1810.  
  1811. return;
  1812.  
  1813. }
  1814.  
  1815.  
  1816.  
  1817. Session.SendMessage(new ThreadsListDataComposer(Forum, Session, Int2, Int3));
  1818.  
  1819. }
  1820.  
  1821. }
  1822.  
  1823. }
  1824.  
  1825.  
  1826.  
  1827. [/CODE]
  1828.  
  1829. UpdateForumReadMarkerEvent.cs
  1830.  
  1831. [CODE]using Plus.HabboHotel.GameClients;
  1832.  
  1833. using System;
  1834.  
  1835. using System.Collections.Generic;
  1836.  
  1837. using System.Linq;
  1838.  
  1839. using System.Text;
  1840.  
  1841. using System.Threading.Tasks;
  1842.  
  1843.  
  1844.  
  1845. namespace Plus.Communication.Packets.Incoming.Groups
  1846.  
  1847. {
  1848.  
  1849. class UpdateForumReadMarkerEvent : IPacketEvent
  1850.  
  1851. {
  1852.  
  1853. public void Parse(GameClient Session, ClientPacket Packet)
  1854.  
  1855. {
  1856.  
  1857. var length = Packet.PopInt();
  1858.  
  1859. for (var i = 0; i < length; i++)
  1860.  
  1861. {
  1862.  
  1863. var forumid = Packet.PopInt();
  1864.  
  1865. var postid = Packet.PopInt();
  1866.  
  1867. var readall = Packet.PopBoolean();
  1868.  
  1869.  
  1870.  
  1871. var forum = PlusEnvironment.GetGame().GetGroupForumManager().GetForum(forumid);
  1872.  
  1873. if (forum == null)
  1874.  
  1875. continue;
  1876.  
  1877.  
  1878.  
  1879. var post = forum.GetPost(postid);
  1880.  
  1881. if (post == null)
  1882.  
  1883. continue;
  1884.  
  1885.  
  1886.  
  1887. var thread = post.ParentThread;
  1888.  
  1889. var index = thread.Posts.IndexOf(post);
  1890.  
  1891. thread.AddView(Session.GetHabbo().Id, index + 1);
  1892.  
  1893.  
  1894.  
  1895. }
  1896.  
  1897. //TODO thread.AddView(Session.GetHabbo().Id);
  1898.  
  1899. }
  1900.  
  1901. }
  1902.  
  1903. }
  1904.  
  1905. [/CODE]
  1906.  
  1907. UpdateForumSettingsEvent.cs
  1908.  
  1909. [CODE]using Plus.Communication.Packets.Outgoing.Groups;
  1910.  
  1911. using Plus.HabboHotel.GameClients;
  1912.  
  1913. using System;
  1914.  
  1915. using System.Collections.Generic;
  1916.  
  1917. using System.Linq;
  1918.  
  1919. using System.Text;
  1920.  
  1921. using System.Threading.Tasks;
  1922.  
  1923.  
  1924.  
  1925. namespace Plus.Communication.Packets.Incoming.Groups
  1926.  
  1927. {
  1928.  
  1929. class UpdateForumSettingsEvent : IPacketEvent
  1930.  
  1931. {
  1932.  
  1933. public void Parse(GameClient Session, ClientPacket Packet)
  1934.  
  1935. {
  1936.  
  1937. var ForumId = Packet.PopInt();
  1938.  
  1939. var WhoCanRead = Packet.PopInt();
  1940.  
  1941. var WhoCanReply = Packet.PopInt();
  1942.  
  1943. var WhoCanPost = Packet.PopInt();
  1944.  
  1945. var WhoCanMod = Packet.PopInt();
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951. var forum = PlusEnvironment.GetGame().GetGroupForumManager().GetForum(ForumId);
  1952.  
  1953.  
  1954.  
  1955. if (forum == null)
  1956.  
  1957. {
  1958.  
  1959. Session.SendNotification("Forum not found 404!");
  1960.  
  1961. return;
  1962.  
  1963. }
  1964.  
  1965.  
  1966.  
  1967. if (forum.Settings.GetReasonForNot(Session, forum.Settings.WhoCanModerate) != "")
  1968.  
  1969. {
  1970.  
  1971. Session.SendNotification("Can't update thread, you don't have the correct rights!");
  1972.  
  1973. return;
  1974.  
  1975. }
  1976.  
  1977.  
  1978.  
  1979. forum.Settings.WhoCanRead = WhoCanRead;
  1980.  
  1981. forum.Settings.WhoCanModerate = WhoCanMod;
  1982.  
  1983. forum.Settings.WhoCanPost = WhoCanReply;
  1984.  
  1985. forum.Settings.WhoCanInitDiscussions = WhoCanPost;
  1986.  
  1987.  
  1988.  
  1989. forum.Settings.Save();
  1990.  
  1991. PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModRoomFilterSeen", 1);
  1992.  
  1993. Session.SendMessage(new ForumDataComposer(forum, Session));
  1994.  
  1995. Session.SendMessage(new ThreadsListDataComposer(forum, Session));
  1996.  
  1997.  
  1998.  
  1999. }
  2000.  
  2001. }
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007. }
  2008.  
  2009. [/CODE]
  2010.  
  2011. UpdateForumThreadStatusEvent.cs
  2012.  
  2013. [CODE]using Plus.HabboHotel.GameClients;
  2014.  
  2015. using System;
  2016.  
  2017. using System.Collections.Generic;
  2018.  
  2019. using System.Linq;
  2020.  
  2021. using System.Text;
  2022.  
  2023. using System.Threading.Tasks;
  2024.  
  2025.  
  2026.  
  2027. namespace Plus.Communication.Packets.Incoming.Groups
  2028.  
  2029. {
  2030.  
  2031. public class UpdateForumThreadStatusEvent : IPacketEvent
  2032.  
  2033. {
  2034.  
  2035. public void Parse(GameClient Session, ClientPacket Packet)
  2036.  
  2037. {
  2038.  
  2039. var ForumID = Packet.PopInt();
  2040.  
  2041. var ThreadID = Packet.PopInt();
  2042.  
  2043. var Pinned = Packet.PopBoolean();
  2044.  
  2045. var Locked = Packet.PopBoolean();
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051. var forum = PlusEnvironment.GetGame().GetGroupForumManager().GetForum(ForumID);
  2052.  
  2053. var thread = forum.GetThread(ThreadID);
  2054.  
  2055.  
  2056.  
  2057. if (forum.Settings.GetReasonForNot(Session, forum.Settings.WhoCanModerate) != "")
  2058.  
  2059. {
  2060.  
  2061. Session.SendNotification("You are not admin on this Thread!");
  2062.  
  2063. return;
  2064.  
  2065. }
  2066.  
  2067.  
  2068.  
  2069. bool isPining = thread.Pinned != Pinned,
  2070.  
  2071. isLocking = thread.Locked != Locked;
  2072.  
  2073.  
  2074.  
  2075. thread.Pinned = Pinned;
  2076.  
  2077. thread.Locked = Locked;
  2078.  
  2079.  
  2080.  
  2081. thread.Save();
  2082.  
  2083.  
  2084.  
  2085. Session.SendMessage(new Outgoing.Groups.ThreadUpdatedComposer(Session, thread));
  2086.  
  2087.  
  2088.  
  2089. if (isPining)
  2090.  
  2091. if (Pinned)
  2092.  
  2093. Session.SendMessage(new Outgoing.Rooms.Notifications.RoomNotificationComposer("forums.thread.pinned"));
  2094.  
  2095. else
  2096.  
  2097. Session.SendMessage(new Outgoing.Rooms.Notifications.RoomNotificationComposer("forums.thread.unpinned"));
  2098.  
  2099.  
  2100.  
  2101. if (isLocking)
  2102.  
  2103. if (Locked)
  2104.  
  2105. Session.SendMessage(new Outgoing.Rooms.Notifications.RoomNotificationComposer("forums.thread.locked"));
  2106.  
  2107. else
  2108.  
  2109. Session.SendMessage(new Outgoing.Rooms.Notifications.RoomNotificationComposer("forums.thread.unlocked"));
  2110.  
  2111.  
  2112.  
  2113. }
  2114.  
  2115. }
  2116.  
  2117. }
  2118.  
  2119. [/CODE]
  2120.  
  2121.  
  2122.  
  2123. Ok, incoming is done. Now for Outgoing add these to the folder Groups.
  2124.  
  2125.  
  2126.  
  2127. ForumDataComposer.cs
  2128.  
  2129. [CODE]using Plus.HabboHotel.GameClients;
  2130.  
  2131. using Plus.HabboHotel.Groups.Forums;
  2132.  
  2133. using System;
  2134.  
  2135. using System.Collections.Generic;
  2136.  
  2137. using System.Linq;
  2138.  
  2139. using System.Text;
  2140.  
  2141. using System.Threading.Tasks;
  2142.  
  2143.  
  2144.  
  2145. namespace Plus.Communication.Packets.Outgoing.Groups
  2146.  
  2147. {
  2148.  
  2149. class ForumDataComposer : ServerPacket
  2150.  
  2151. {
  2152.  
  2153. public ForumDataComposer(GroupForum Forum, GameClient Session)
  2154.  
  2155. : base(ServerPacketHeader.ForumDataMessageComposer)
  2156.  
  2157. {
  2158.  
  2159. base.WriteInteger(Forum.Id);
  2160.  
  2161. base.WriteString(Forum.Group.Name);
  2162.  
  2163. base.WriteString(Forum.Group.Description);
  2164.  
  2165. base.WriteString(Forum.Group.Badge);
  2166.  
  2167.  
  2168.  
  2169. base.WriteInteger(Forum.Threads.Count);
  2170.  
  2171. base.WriteInteger(0);
  2172.  
  2173. base.WriteInteger(0);
  2174.  
  2175. base.WriteInteger(0);
  2176.  
  2177. base.WriteInteger(0);
  2178.  
  2179. base.WriteInteger(0);
  2180.  
  2181. base.WriteString("not_member");
  2182.  
  2183. base.WriteInteger(0);
  2184.  
  2185.  
  2186.  
  2187. base.WriteInteger(Forum.Settings.WhoCanRead);
  2188.  
  2189. base.WriteInteger(Forum.Settings.WhoCanPost);
  2190.  
  2191. base.WriteInteger(Forum.Settings.WhoCanInitDiscussions);
  2192.  
  2193. base.WriteInteger(Forum.Settings.WhoCanModerate);
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199. base.WriteString(Forum.Settings.GetReasonForNot(Session, Forum.Settings.WhoCanRead));
  2200.  
  2201. base.WriteString(Forum.Settings.GetReasonForNot(Session, Forum.Settings.WhoCanPost));
  2202.  
  2203. base.WriteString(Forum.Settings.GetReasonForNot(Session, Forum.Settings.WhoCanInitDiscussions));
  2204.  
  2205. base.WriteString(Forum.Settings.GetReasonForNot(Session, Forum.Settings.WhoCanModerate));
  2206.  
  2207. base.WriteString("-System");
  2208.  
  2209.  
  2210.  
  2211. base.WriteBoolean(Forum.Group.CreatorId == Session.GetHabbo().Id);
  2212.  
  2213. base.WriteBoolean(Forum.Group.IsAdmin(Session.GetHabbo().Id) && Forum.Settings.GetReasonForNot(Session, Forum.Settings.WhoCanModerate) == "");
  2214.  
  2215.  
  2216.  
  2217. }
  2218.  
  2219. }
  2220.  
  2221. }
  2222.  
  2223. [/CODE]
  2224.  
  2225. ForumsListDataComposer.cs
  2226.  
  2227. [CODE]using Plus.HabboHotel.GameClients;
  2228.  
  2229. using Plus.HabboHotel.Groups.Forums;
  2230.  
  2231. using System;
  2232.  
  2233. using System.Collections.Generic;
  2234.  
  2235. using System.Linq;
  2236.  
  2237. using System.Text;
  2238.  
  2239. using System.Threading.Tasks;
  2240.  
  2241.  
  2242.  
  2243. namespace Plus.Communication.Packets.Outgoing.Groups
  2244.  
  2245. {
  2246.  
  2247. class ForumsListDataComposer : ServerPacket
  2248.  
  2249. {
  2250.  
  2251. public ForumsListDataComposer(ICollection<GroupForum> Forums, GameClient Session, int ViewOrder = 0, int StartIndex = 0, int MaxLength = 20)
  2252.  
  2253. : base(ServerPacketHeader.ForumsListDataMessageComposer)
  2254.  
  2255. {
  2256.  
  2257. base.WriteInteger(ViewOrder);
  2258.  
  2259. base.WriteInteger(StartIndex);
  2260.  
  2261. base.WriteInteger(StartIndex);
  2262.  
  2263.  
  2264.  
  2265. base.WriteInteger(Forums.Count());
  2266.  
  2267.  
  2268.  
  2269. foreach (var Forum in Forums)
  2270.  
  2271. {
  2272.  
  2273. var lastpost = Forum.GetLastPost();
  2274.  
  2275. var isn = lastpost == null;
  2276.  
  2277. base.WriteInteger(Forum.Id);
  2278.  
  2279. base.WriteString(Forum.Name);
  2280.  
  2281. base.WriteString(Forum.Description);
  2282.  
  2283. base.WriteString(Forum.Group.Badge);
  2284.  
  2285. base.WriteInteger(0);
  2286.  
  2287. base.WriteInteger(0);
  2288.  
  2289. base.WriteInteger(Forum.MessagesCount);
  2290.  
  2291. base.WriteInteger(Forum.UnreadMessages(Session.GetHabbo().Id));
  2292.  
  2293. base.WriteInteger(0);
  2294.  
  2295. base.WriteInteger(!isn ? lastpost.GetAuthor().Id : 0);
  2296.  
  2297. base.WriteString(!isn ? lastpost.GetAuthor().Username : "");
  2298.  
  2299. base.WriteInteger(!isn ? (int)PlusEnvironment.GetUnixTimestamp() - lastpost.Timestamp : 0);
  2300.  
  2301. }
  2302.  
  2303. }
  2304.  
  2305. }
  2306.  
  2307. }
  2308.  
  2309. [/CODE]
  2310.  
  2311. PostUpdatedComposer.cs
  2312.  
  2313. [CODE]using Plus.HabboHotel.GameClients;
  2314.  
  2315. using Plus.HabboHotel.Groups.Forums;
  2316.  
  2317. using System;
  2318.  
  2319. using System.Collections.Generic;
  2320.  
  2321. using System.Linq;
  2322.  
  2323. using System.Text;
  2324.  
  2325. using System.Threading.Tasks;
  2326.  
  2327.  
  2328.  
  2329. namespace Plus.Communication.Packets.Outgoing.Groups
  2330.  
  2331. {
  2332.  
  2333. class PostUpdatedComposer : ServerPacket
  2334.  
  2335. {
  2336.  
  2337. public PostUpdatedComposer(GameClient Session, GroupForumThreadPost Post)
  2338.  
  2339. : base(ServerPacketHeader.PostUpdatedMessageComposer)
  2340.  
  2341. {
  2342.  
  2343. base.WriteInteger(Post.ParentThread.ParentForum.Id);
  2344.  
  2345. base.WriteInteger(Post.ParentThread.Id);
  2346.  
  2347.  
  2348.  
  2349. Post.SerializeData(Session, this);
  2350.  
  2351. }
  2352.  
  2353. }
  2354.  
  2355. }
  2356.  
  2357. [/CODE]
  2358.  
  2359. ThreadCreatedComposer.cs
  2360.  
  2361. [CODE]using Plus.HabboHotel.GameClients;
  2362.  
  2363. using Plus.HabboHotel.Groups.Forums;
  2364.  
  2365. using System;
  2366.  
  2367. using System.Collections.Generic;
  2368.  
  2369. using System.Linq;
  2370.  
  2371. using System.Text;
  2372.  
  2373. using System.Threading.Tasks;
  2374.  
  2375.  
  2376.  
  2377. namespace Plus.Communication.Packets.Outgoing.Groups
  2378.  
  2379. {
  2380.  
  2381. public class ThreadCreatedComposer : ServerPacket
  2382.  
  2383. {
  2384.  
  2385. public ThreadCreatedComposer(GameClient Session, GroupForumThread Thread)
  2386.  
  2387. : base(ServerPacketHeader.ThreadCreatedMessageComposer)
  2388.  
  2389. {
  2390.  
  2391.  
  2392.  
  2393. base.WriteInteger(Thread.ParentForum.Id);
  2394.  
  2395. base.WriteInteger(Thread.Id);
  2396.  
  2397. base.WriteInteger(Thread.GetAuthor().Id);
  2398.  
  2399. base.WriteString(Thread.GetAuthor().Username);
  2400.  
  2401. base.WriteString(Thread.Caption);
  2402.  
  2403. base.WriteBoolean(false);
  2404.  
  2405. base.WriteBoolean(false);
  2406.  
  2407. base.WriteInteger(1);
  2408.  
  2409. base.WriteInteger(Thread.Posts.Count);
  2410.  
  2411. base.WriteInteger(Thread.GetUnreadMessages(Session.GetHabbo().Id));
  2412.  
  2413. base.WriteInteger(0);
  2414.  
  2415. base.WriteInteger(0);
  2416.  
  2417.  
  2418.  
  2419. base.WriteString("Unknown");
  2420.  
  2421. base.WriteInteger(65);
  2422.  
  2423.  
  2424.  
  2425. base.WriteByte(0);
  2426.  
  2427. base.WriteInteger(10);
  2428.  
  2429. base.WriteString("Str4");
  2430.  
  2431. base.WriteInteger(11);
  2432.  
  2433. }
  2434.  
  2435. }
  2436.  
  2437. }
  2438.  
  2439. [/CODE]
  2440.  
  2441. ThreadDataComposer.cs
  2442.  
  2443. [CODE]using Plus.HabboHotel.GameClients;
  2444.  
  2445. using Plus.HabboHotel.Groups.Forums;
  2446.  
  2447. using System;
  2448.  
  2449. using System.Collections.Generic;
  2450.  
  2451. using System.Linq;
  2452.  
  2453. using System.Text;
  2454.  
  2455. using System.Threading.Tasks;
  2456.  
  2457.  
  2458.  
  2459. namespace Plus.Communication.Packets.Outgoing.Groups
  2460.  
  2461. {
  2462.  
  2463. class ThreadDataComposer : ServerPacket
  2464.  
  2465. {
  2466.  
  2467. public ThreadDataComposer(GameClient session, GroupForumThread Thread, int StartIndex, int MaxLength)
  2468.  
  2469. : base(ServerPacketHeader.ThreadDataMessageComposer)
  2470.  
  2471. {
  2472.  
  2473. base.WriteInteger(Thread.ParentForum.Id);
  2474.  
  2475. base.WriteInteger(Thread.Id);
  2476.  
  2477. base.WriteInteger(StartIndex);
  2478.  
  2479. base.WriteInteger(Thread.Posts.Count);
  2480.  
  2481.  
  2482.  
  2483. foreach (var Post in Thread.Posts)
  2484.  
  2485. {
  2486.  
  2487. Post.SerializeData(session, this);
  2488.  
  2489.  
  2490.  
  2491. }
  2492.  
  2493.  
  2494.  
  2495. }
  2496.  
  2497. }
  2498.  
  2499. }
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505. [/CODE]
  2506.  
  2507. ThreadReplyComposer.cs
  2508.  
  2509. [CODE]using Plus.HabboHotel.GameClients;
  2510.  
  2511. using Plus.HabboHotel.Groups.Forums;
  2512.  
  2513. using System;
  2514.  
  2515. using System.Collections.Generic;
  2516.  
  2517. using System.Linq;
  2518.  
  2519. using System.Text;
  2520.  
  2521. using System.Threading.Tasks;
  2522.  
  2523.  
  2524.  
  2525. namespace Plus.Communication.Packets.Outgoing.Groups
  2526.  
  2527. {
  2528.  
  2529. class ThreadReplyComposer : ServerPacket
  2530.  
  2531. {
  2532.  
  2533. public ThreadReplyComposer(GameClient Session, GroupForumThreadPost Post)
  2534.  
  2535. : base(ServerPacketHeader.ThreadReplyMessageComposer)
  2536.  
  2537. {
  2538.  
  2539. var User = Post.GetAuthor();
  2540.  
  2541. base.WriteInteger(Post.ParentThread.ParentForum.Id);
  2542.  
  2543. base.WriteInteger(Post.ParentThread.Id);
  2544.  
  2545.  
  2546.  
  2547. base.WriteInteger(Post.Id);
  2548.  
  2549. base.WriteInteger(Post.ParentThread.Posts.IndexOf(Post));
  2550.  
  2551.  
  2552.  
  2553. base.WriteInteger(User.Id);
  2554.  
  2555. base.WriteString(User.Username);
  2556.  
  2557. base.WriteString(User.Look);
  2558.  
  2559.  
  2560.  
  2561. base.WriteInteger((int)(PlusEnvironment.GetUnixTimestamp() - Post.Timestamp));
  2562.  
  2563. base.WriteString(Post.Message);
  2564.  
  2565. base.WriteByte(0);
  2566.  
  2567. base.WriteInteger(0);
  2568.  
  2569. base.WriteString("");
  2570.  
  2571. base.WriteInteger(10);
  2572.  
  2573. base.WriteInteger(Post.ParentThread.GetUserPosts(User.Id).Count);
  2574.  
  2575. }
  2576.  
  2577. }
  2578.  
  2579. }
  2580.  
  2581. [/CODE]
  2582.  
  2583. ThreadListDataComposer.cs
  2584.  
  2585. [CODE]using Plus.HabboHotel.GameClients;
  2586.  
  2587. using Plus.HabboHotel.Groups.Forums;
  2588.  
  2589. using System;
  2590.  
  2591. using System.Collections.Generic;
  2592.  
  2593. using System.Linq;
  2594.  
  2595. using System.Text;
  2596.  
  2597. using System.Threading.Tasks;
  2598.  
  2599.  
  2600.  
  2601. namespace Plus.Communication.Packets.Outgoing.Groups
  2602.  
  2603. {
  2604.  
  2605. class ThreadsListDataComposer : ServerPacket
  2606.  
  2607. {
  2608.  
  2609. public ThreadsListDataComposer(GroupForum Forum, GameClient Session, int StartIndex = 0, int MaxLength = 20)
  2610.  
  2611. : base(ServerPacketHeader.ThreadsListDataMessageComposer)
  2612.  
  2613. {
  2614.  
  2615. base.WriteInteger(Forum.GroupId);
  2616.  
  2617. base.WriteInteger(StartIndex);
  2618.  
  2619.  
  2620.  
  2621. var Threads = Forum.Threads;
  2622.  
  2623. if (Threads.Count - 1 >= StartIndex)
  2624.  
  2625. Threads = Threads.GetRange(StartIndex, Math.Min(MaxLength, Threads.Count - StartIndex));
  2626.  
  2627.  
  2628.  
  2629. base.WriteInteger(Threads.Count);
  2630.  
  2631.  
  2632.  
  2633. foreach (var Thread in Threads)
  2634.  
  2635. {
  2636.  
  2637. Thread.SerializeData(Session, this);
  2638.  
  2639. }
  2640.  
  2641. }
  2642.  
  2643. }
  2644.  
  2645. }
  2646.  
  2647.  
  2648.  
  2649. [/CODE]
  2650.  
  2651. ThreadUpdatedComposer.cs
  2652.  
  2653. [CODE]using Plus.HabboHotel.GameClients;
  2654.  
  2655. using Plus.HabboHotel.Groups.Forums;
  2656.  
  2657. using System;
  2658.  
  2659. using System.Collections.Generic;
  2660.  
  2661. using System.Linq;
  2662.  
  2663. using System.Text;
  2664.  
  2665. using System.Threading.Tasks;
  2666.  
  2667.  
  2668.  
  2669. namespace Plus.Communication.Packets.Outgoing.Groups
  2670.  
  2671. {
  2672.  
  2673. class ThreadUpdatedComposer : ServerPacket
  2674.  
  2675. {
  2676.  
  2677. public ThreadUpdatedComposer(GameClient Session, GroupForumThread Thread)
  2678.  
  2679. : base(ServerPacketHeader.ThreadUpdatedMessageComposer)
  2680.  
  2681. {
  2682.  
  2683. base.WriteInteger(Thread.ParentForum.Id);
  2684.  
  2685.  
  2686.  
  2687. Thread.SerializeData(Session, this);
  2688.  
  2689. }
  2690.  
  2691. }
  2692.  
  2693. }
  2694.  
  2695. [/CODE]
  2696.  
  2697.  
  2698.  
  2699. Ok, now goto Game.cs and add
  2700.  
  2701.  
  2702.  
  2703. [CODE]private readonly GroupForumManager _groupForumManager;
  2704.  
  2705. [/CODE]
  2706.  
  2707. Then inside Game() Add
  2708.  
  2709. [CODE] this._groupForumManager = new GroupForumManager();
  2710.  
  2711. [/CODE]
  2712.  
  2713. [CODE] public GroupForumManager GetGroupForumManager()
  2714.  
  2715. {
  2716.  
  2717. return _groupForumManager;
  2718.  
  2719. }[/CODE]
  2720.  
  2721.  
  2722.  
  2723. Ok, ServerPacketHeader.cs
  2724.  
  2725. [CODE] public const int ForumsListDataMessageComposer = 1539;//3596
  2726.  
  2727. public const int ForumDataMessageComposer = 91;//254
  2728.  
  2729. public const int ThreadCreatedMessageComposer = 2675;//3683
  2730.  
  2731. public const int ThreadDataMessageComposer = 2526;//879
  2732.  
  2733. public const int ThreadsListDataMessageComposer = 1056;//1538
  2734.  
  2735. public const int ThreadUpdatedMessageComposer = 951;//3226
  2736.  
  2737. public const int ThreadReplyMessageComposer = 1003;//1936[/CODE]
  2738.  
  2739. ClientPacketHeader.cs
  2740.  
  2741. [CODE] public const int PostGroupContentMessageEvent = 1499;//477
  2742.  
  2743. public const int GetForumStatsMessageEvent = 1126;//872
  2744.  
  2745. public const int UpdateForumReadMarkerMessageEvent = 1659;
  2746.  
  2747. public const int UpdateForumSettingsMessageEvent = 3295;//931
  2748.  
  2749. public const int UpdateForumThreadStatusMessageEvent = 2980;
  2750.  
  2751. public const int GetForumUserProfileMessageEvent = 3515;//2639
  2752.  
  2753. public const int GetForumsListDataMessageEvent = 3802;//3912
  2754.  
  2755. [/CODE]
  2756.  
  2757.  
  2758.  
  2759. Then goto groupManager and replace TryGetGroup() with this.
  2760.  
  2761. [CODE]public bool TryGetGroup(int id, out Group Group)
  2762.  
  2763. {
  2764.  
  2765. Group = null;
  2766.  
  2767. if (this._groups.ContainsKey(id))
  2768.  
  2769. return this._groups.TryGetValue(id, out Group);
  2770.  
  2771. lock (this._groupLoadingSync)
  2772.  
  2773. {
  2774.  
  2775. if (this._groups.ContainsKey(id))
  2776.  
  2777. return this._groups.TryGetValue(id, out Group);
  2778.  
  2779. DataRow Row = null;
  2780.  
  2781. using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
  2782.  
  2783. {
  2784.  
  2785. dbClient.SetQuery("SELECT * FROM `groups` WHERE `id` = @id LIMIT 1");
  2786.  
  2787. dbClient.AddParameter("id", id);
  2788.  
  2789. Row = dbClient.getRow();
  2790.  
  2791. if (Row != null)
  2792.  
  2793. {
  2794.  
  2795. Group = new Group(
  2796.  
  2797. Convert.ToInt32(Row["id"]), Convert.ToString(Row["name"]), Convert.ToString(Row["desc"]), Convert.ToString(Row["badge"]), Convert.ToInt32(Row["room_id"]), Convert.ToInt32(Row["owner_id"]),
  2798.  
  2799. Convert.ToInt32(Row["created"]), Convert.ToInt32(Row["state"]), Convert.ToInt32(Row["colour1"]), Convert.ToInt32(Row["colour2"]), Convert.ToInt32(Row["admindeco"]), Convert.ToInt32(Row["has_forum"]) == 1, Convert.ToInt32(Row["has_chat"]) == 1);
  2800.  
  2801. this._groups.TryAdd(Group.Id, Group);
  2802.  
  2803. return true;
  2804.  
  2805. }
  2806.  
  2807. }
  2808.  
  2809. }
  2810.  
  2811. return false;
  2812.  
  2813. }[/CODE]
  2814.  
  2815. then goto your Groups tabe and add has_forum enum '0','1' default '0'.
  2816.  
  2817.  
  2818.  
  2819. I'll post Queries in a minute.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement