Register for your free account! | Forgot your password?

You last visited: Today at 03:50

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



MessageBoard

Discussion on MessageBoard within the CO2 Private Server forum part of the Conquer Online 2 category.

Closed Thread
 
Old   #1
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
MessageBoard

Well, I've never implemented it, but I was getting "Unknown packet: 1111" from players trying to use it, so I decided to go for it. Through trial and error, I found what I believe to be the right packet for displaying the list of messages, however even if there are multiple messages, the last one overwrites any that were before it. I'm sure there's something I'm supposed to change, but I haven't figured it out yet. Here's my packet.

Code:
        public static byte[] MessageBoard(MessageBoardPost Post, int Page)
        {
            string Msg = Post.Message;
            if (Msg.Length > 50)
                Msg = Msg.Substring(0, 50);
            Packet Packet = new Packet(13 + (Post.Poster.Length + Msg.Length + Post.TimeStamp.Length), 1111);
            Packet.Short(Page); // Assuming this is the page, since it does nothing atm.
            Packet.Short((int)Post.Board); // The board type, aka TradeBoard, FriendBoard, ...
            Packet.Byte(3); // Flag - Should always be 3? 3=Send List
            Packet.Byte(3); // String Count
            Packet.String(Post.Poster, true); // Poster's name
            Packet.String(Msg, true); // The [truncated] message
            Packet.String(Post.TimeStamp, true); // And the timestamp, YYYY-MM-DD-HH-MM
            return Packet.Buffer; 
        }
The bool "true" passed to the string function simply means that it should send a byte containing the length first, thus why the packet length is 13 + (string lengths)

Anywho, a shove in the right direction would be awesome.

Edit: Also, everything else works, including viewing messages in full. The number of items displayed is my only problem.
Zeroxelli is offline  
Thanks
3 Users
Old 05/24/2012, 23:45   #2
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
Took it from my VERY... VERY... VERYYY Old source.... :]
hope it helps

Its not the best system... but it works... so implement it the best way you can... i'll do it in my new source when i get the packet handling system fully working :]

packet:

Handler:
12tails is offline  
Thanks
5 Users
Old 05/25/2012, 00:39   #3
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by 12tails View Post
Took it from my VERY... VERY... VERYYY Old source.... :]
hope it helps

Its not the best system... but it works... so implement it the best way you can... i'll do it in my new source when i get the packet handling system fully working :]

packet:

Handler:
Ahh okay, so I was right in assuming that I should just put my foreach inside the packet itself, and use one packet for the entire page. Just got home, so I'll confirm that in a second here. Thanks dude

Edit: Okay, finally got to sit down. Anyway, it worked, thank you Here's my packet now
Code:
        public static byte[] MessageBoard(ChatType Board, int Page)
        {
            int TotalStringLength = 0;

            List<MessageBoardPost> Posts = new List<MessageBoardPost>();

            int PostsAdded = 0;
            int Skip = (Page * 10);
            foreach (MessageBoardPost Post in Program.MessageBoard.Values)
            {
                if (Skip > 0)
                {
                    Skip--;
                    continue;
                }
                Posts.Add(Post);
                PostsAdded++;
                TotalStringLength += (Post.Poster.Length + (Post.Message.Length > 50 ? 50 : Post.Message.Length) + Post.TimeStamp.Length);
                if (PostsAdded == 10) break;
            }

            Packet Packet = new Packet(10 + TotalStringLength + (3 * Posts.Count), 1111);
            Packet.Short(Page); // Assuming this is the page, since it does nothing atm.
            Packet.Short((int)Board); // The board type, aka TradeBoard, FriendBoard, ...
            Packet.Byte(3); // Flag - Should always be 3? 3=Send List
            Packet.Byte(3 * Posts.Count); // String Count
            foreach (MessageBoardPost Post in Posts)// If we wanted to display oldest first, we'd replace Posts with Posts.Reverse<MessageBoardPost>()
            {
                string Msg = Post.Message;
                if (Msg.Length > 50)
                    Msg = Msg.Substring(0, 50);
                Packet.String(Post.Poster, 0, true); // Poster's name
                Packet.String(Msg, 0, true); // The [truncated] message
                Packet.String(Post.TimeStamp, 0, true); // And the timestamp, YYYY-MM-DD-HH-MM
            }
            return Packet.Buffer; 
        }
Don't know if I'm going to fully implement pages yet, as I want it to sorta be where people sell things.
Zeroxelli is offline  
Thanks
2 Users
Old 05/25/2012, 01:32   #4
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
Nice ^^

good luck with your server bro... if u need some other packet for lower patches.... just let me know .... cya!
12tails is offline  
Closed Thread


Similar Threads Similar Threads
MessageBoard PacketID?
07/26/2009 - CO2 Private Server - 5 Replies
Heya. Was just wondering if anyone has the messageboard packetid to make a text be written in the messageboard. I got so far that I can get what message the user inputs in the window, but not sure how to get it to write a text in the board. Thanks.



All times are GMT +1. The time now is 03:51.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.