Beispiel #1
0
        /// <summary>
        /// Save the player into the database
        /// </summary>
        public bool SaveIntoDatabase()
        {
            try
            {
                if (m_character.IsDirty)
                {
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        db.UpdatePlayer(m_character);
                        //db.UpdateVIPInfo(m_character);
                    }
                }

                MainBag.SaveToDatabase();
                PropBag.SaveToDatabase();
                StoreBag.SaveToDatabase();
                //CardBag.SaveToDatabase();
                QuestInventory.SaveToDatabase();
                BufferList.SaveToDatabase();
                return true;
            }
            catch (Exception e)
            {
                log.Error("Error saving player " + m_character.NickName + "!", e);
                return false;
            }
        }
Beispiel #2
0
 public bool LoadFromDatabase()
 {
     using (PlayerBussiness db = new PlayerBussiness())
     {
         PlayerInfo detail = db.GetUserSingleByUserID(m_character.ID);
         if (detail == null)
         {
             Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid"));
             Client.Disconnect();
             return false;
         }
         else
         {
             m_character = detail;
         }
         ChargeToUser();
         int[] sole = new int[] { 0, 1, 2 };
         Out.SendUpdateInventorySlot(FightBag, sole);
         UpdateItemForUser(1);
         UpdateVIPForUser();
         //AddGP(0);
         UpdateWeapon(m_mainBag.GetItemAt(6));
         UpdateSecondWeapon(m_mainBag.GetItemAt(15));
         m_pvepermissions = string.IsNullOrEmpty(detail.PvePermission) ? InitPvePermission() : m_converter.GetBytes(detail.PvePermission);
         _friends = new Dictionary<int, int>();
         _friends = db.GetFriendsIDAll(m_character.ID);
         m_character.State = 1;
         db.UpdatePlayer(m_character);
         //  db.UpdateVIPInfo(m_character);
         return true;
     }
 }