Packet 1033 (Date/Time).

01/31/2020 01:44 - RuShi -#1
How can I show the current time of the host and I know it's Packet 1033.
Code:
MSG_DATE_TIME = 1033
Now, I cannot handle this complicated calculation or at least force it to read the real date and time of the host.

Here's the code:
Code:
public unsafe struct ServerTimePacket
    {
        public DateTime Time;

        public static ServerTimePacket Create()
        {
            var packet = new ServerTimePacket
            {
                Time = DateTime.UtcNow
                    .AddHours(Constants.TIME_ADJUST_HOUR)
                    .AddMinutes(Constants.TIME_ADJUST_MIN)
                    .AddSeconds(Constants.TIME_ADJUST_SEC)
            };
            return packet;
        }

        public static implicit operator byte[](ServerTimePacket packet)
        {
            var buffer = new byte[36 + 8];
            fixed (byte* ptr = buffer)
            {
                PacketBuilder.AppendHeader(ptr, buffer.Length, Constants.MSG_DATE_TIME);
                *((int*)(ptr + 8)) = packet.Time.Year - 1900;
                *((int*)(ptr + 12)) = packet.Time.Month - 1;
                *((int*)(ptr + 16)) = packet.Time.DayOfYear;
                *((int*)(ptr + 20)) = packet.Time.Day;
                *((int*)(ptr + 24)) = packet.Time.Hour;
                *((int*)(ptr + 28)) = packet.Time.Minute;
                *((int*)(ptr + 32)) = packet.Time.Second;
            }
            return buffer;
        }
    }
Please, I cannot open discussions about the author or anything related to the base.
Note, I have someone who are coding for me but he is busy at the moment so I decided to get a free help if there is anyone who can.
01/31/2020 09:03 ~Crystaline#2
Code:
public static ServerTimePacket Create()
        {
            var packet = new ServerTimePacket
            {
                Time = DateTime.Now
            };
            return packet;
        }
I'm not sure if it works, but at least give it a try.
01/31/2020 11:24 Spirited#3
You can replace the UtcNow call with just Now. That should use your local time by default. Guide on DateTime, just fyi: [Only registered and activated users can see links. Click Here To Register...]