DarkEmu_GameServer.PacketReader.ReadByteArray C# (CSharp) Method

ReadByteArray() public method

public ReadByteArray ( int count ) : byte[]
count int
return byte[]
        public byte[] ReadByteArray(int count)
        {
            byte[] tmp = new byte[count];
            for (int i = 0; i < count; i++)
                tmp[i] = ReadByte();
            return tmp;
        }

Usage Example

Example #1
0
        private static void OnChatPublic(PacketReader reader_, int Index_)
        {
            ushort msglen = reader_.ReadWord();

            byte[] bmsg = reader_.ReadByteArray(msglen * 2);

            if (Player.Flags[Index_].GM == 1)
            {
                string msg = Encoding.Unicode.GetString(bmsg);
                if (msg.ToCharArray()[0] == '.' && msg.Contains("level"))
                {
                    string[] tmpString = msg.Split(' ');
                    Stats.GetXP(Index_, Convert.ToUInt64(tmpString[1]), Convert.ToUInt64(tmpString[2]));
                }
            }

            PacketWriter writer = new PacketWriter();

            writer.SetOpcode(SERVER_OPCODES.GAME_SERVER_CHAT);
            writer.AppendByte(1);
            writer.AppendDword(Player.General[Index_].UniqueID);
            writer.AppendWord(msglen);
            writer.AppendByteArray(bmsg, bmsg.Length);
            ServerSocket.SendPacketInRange(writer.getWorkspace(), Index_);
        }
All Usage Examples Of DarkEmu_GameServer.PacketReader::ReadByteArray