Example #1
0
 public static bool LoadEntity(Client.GameClient client)
 {
     using (var cmd = new MySqlCommand(MySqlCommandType.SELECT).Select("characters").Where("UID", client.Account.EntityID))
         using (var reader = new MySqlReader(cmd))
         {
             if (reader.Read())
             {
                 try
                 {
                     client.Entity               = new Entity();
                     client.Entity.Owner         = client;
                     client.Entity.UID           = reader.ReadUInt32("UID");
                     client.Entity.Experience    = reader.ReadUInt32("Experience");
                     client.Entity.Clan          = reader.ReadString("Clan");
                     client.Entity.Name          = reader.ReadString("Name");
                     client.Entity.Deserion      = reader.ReadUInt32("Deserion");
                     client.Entity.GeneradeKills = reader.ReadUInt32("GeneradeKills");
                     client.Entity.GP            = reader.ReadUInt32("GP");
                     client.Entity.ZP            = reader.ReadUInt32("ZP");
                     client.Entity.MP            = reader.ReadUInt32("MP");
                     client.Entity.VIP           = reader.ReadBoolean("VIP");
                     client.Entity.HeadshotKills = reader.ReadUInt32("HeadshotKills");
                     client.Entity.KnifeKills    = reader.ReadUInt32("KnifeKills");
                     client.Entity.TeamKills     = reader.ReadUInt32("TeamKills");
                     client.Entity.Settings      = reader.ReadBlob("Settings");
                     client.Entity.Battles       = new System.Collections.Generic.List <Battle>();
                     byte[] Battles = reader.ReadBlob("Battles");
                     if (Battles.Length > 0)
                     {
                         using (var stream = new System.IO.MemoryStream(Battles))
                             using (var rdr = new System.IO.BinaryReader(stream))
                             {
                                 int count = rdr.ReadInt32();
                                 for (int i = 0; i < count; i++)
                                 {
                                     Battle battle = new Battle
                                     {
                                         GameMode = (Enums.GameMode)rdr.ReadByte(),
                                         Won      = rdr.ReadBoolean(),
                                         Kills    = rdr.ReadUInt16(),
                                         Deaths   = rdr.ReadUInt16()
                                     };
                                     client.Entity.Battles.Add(battle);
                                 }
                             }
                     }
                     return(true);
                 }
                 catch (Exception e)
                 {
                     Console.WriteLine(e);
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
 }