void GetFriendsList()
{
//Wrap our function inside a catcher
try
{
//Set new sql query to get friend information
MsSQL ms = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
//Count our friends
int count = ms.Count();
//If we have a friend in the list
if (count > 0)
{
//Send our packet
client.Send(Packet.SendFriendList(Convert.ToByte(count), Character));
//Open new sql data reader
using (SqlDataReader reader = ms.Read())
{
//While our sql data reader is reading
while (reader.Read())
{
//Get player id information of friend
int getid = reader.GetInt32(2);
//Get detailed information for our friend
Systems sys = GetPlayerid(getid);
//If the character is online
if (sys != null)
{
//We send online state change packet
sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, false));
}
}
}
//Close our sql reader
ms.Close();
}
}
catch (Exception ex)
{
Console.WriteLine("Error loading friends list {0} ", ex);
Systems.Debugger.Write(ex);
}
}