Hello just want to ask something on this

09/17/2012 21:39 marlyandedsel#1
PHP Code:
public class Elite_Pk Writer
    
{
        private 
byte[] Packet;
        public 
Elite_Pk(uint clientID)
        {
            
Packet = new byte[356];
            
WriteUInt16(3480Packet);
            
WriteUInt16(22232Packet);
            
Packet[8] = 3;//type
            
Packet[16] = 8// count
            
WriteUInt32(clientID20Packet);
        }
        public 
byte[] ToArray()
        {
         
ushort Position 32;
            
Game.Tournaments.Elite_client[] cometition;
            
cometition Game.Tournaments.EliteTournament.Top8.Values.ToArray();
            for (
byte x 19x++)
            {
                foreach (
Game.Tournaments.Elite_client clients in cometition)
                {
                    if (
== clients.Postion)
                    {
                        
Packet[Position] = (byte)clients.Postion;
                        
Position += 4;
                        
WriteString(clients.NamePositionPacket);
                        
Position += 16;
                        
WriteUInt32(uint.Parse(clients.Avatar.ToString() + clients.Mesh.ToString()), PositionPacket);
                        
Position += 4;
                        
WriteUInt32(clients.UIDPositionPacket);
                        
Position += 12;
                    }
                }
            }
            return 
Packet;
        }
        public 
void Send(Client.GameState client)
        {
            
client.Send(ToArray());
        }
    } 
at this line ushort Position = 32; it said Index was outside of the bound of the Array.

why is happening this, I know someone want to help me about this just confuse :handsdown:
09/17/2012 23:32 pro4never#2
I can guarantee that your error is NOT actually on the line ushort Position = 32 as nothing is actually done in that line besides assigning 2 bytes in memory for the variable "Position" with the value "32"

The actual error likely occurs on Packet[Position] = (byte)clients.Postion;

Check your loop and the Position. If it goes above 355 then you are going to have that error because you are outside the bounds of the array Packet.


Breakpointing + outputting the number of loops being performed would be a fantastic start to finding your issue.
09/18/2012 04:59 marlyandedsel#3
hell yea Pro4 THANKS VERY MUCH FOR THIS... :))

#edit : yes it ends at 356