Esempio n. 1
0
        public GroupForumThreadPost CreatePost(int userid, string message)
        {
            int now = (int)NeonEnvironment.GetUnixTimestamp();
            GroupForumThreadPost Post = new GroupForumThreadPost(this, 0, userid, now, message, 0, 0);

            using (Database.Interfaces.IQueryAdapter adap = NeonEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                adap.SetQuery("INSERT INTO group_forums_thread_posts (thread_id, user_id, message, timestamp) VALUES (@a, @b, @c, @d)");
                adap.AddParameter("a", Id);
                adap.AddParameter("b", userid);
                adap.AddParameter("c", message);
                adap.AddParameter("d", now);
                Post.Id = (int)adap.InsertQuery();
            }

            Posts.Add(Post);
            return(Post);
        }
Esempio n. 2
0
        public void SerializeData(GameClient Session, ServerPacket Packet)
        {
            GroupForumThreadPost lastpost = GetLastMessage();
            bool isn = lastpost == null;

            Packet.WriteInteger(Id);                                                                        //Thread ID
            Packet.WriteInteger(GetAuthor().Id);
            Packet.WriteString(GetAuthor().Username);                                                       //Thread Author
            Packet.WriteString(Caption);                                                                    //Thread Title
            Packet.WriteBoolean(Pinned);                                                                    //Pinned
            Packet.WriteBoolean(Locked);                                                                    //Locked
            Packet.WriteInteger((int)(NeonEnvironment.GetUnixTimestamp() - Timestamp));                     //Created Secs Ago
            Packet.WriteInteger(Posts.Count);                                                               //Message count
            Packet.WriteInteger(GetUnreadMessages(Session.GetHabbo().Id));                                  //Unread message count
            Packet.WriteInteger(1);                                                                         // Message List Lentgh

            Packet.WriteInteger(!isn ? lastpost.GetAuthor().Id : 0);                                        // Las user to message id
            Packet.WriteString(!isn ? lastpost.GetAuthor().Username : "");                                  //Last user to message name
            Packet.WriteInteger(!isn ? (int)(NeonEnvironment.GetUnixTimestamp() - lastpost.Timestamp) : 0); //Last message timestamp

            Packet.WriteByte(DeletedLevel * 10);                                                            //thread Deleted Level

            Habbo deleter = GetDeleter();

            if (deleter != null)
            {
                Packet.WriteInteger(deleter.Id);                                                   // deleter user id
                Packet.WriteString(deleter.Username);                                              //deleter user name
                Packet.WriteInteger((int)(NeonEnvironment.GetUnixTimestamp() - DeletedTimestamp)); //deleted secs ago
            }
            else
            {
                Packet.WriteInteger(1);       // deleter user id
                Packet.WriteString("unknow"); //deleter user name
                Packet.WriteInteger(0);       //deleted secs ago
            }
        }