Ejemplo n.º 1
0
        public static bool GetCharacter(Int32 nAID, byte nIndex, MTD_CharInfo charInfo)
        {
            lock (m_sqlConnection)
            {
                using (SqlCommand sqlCMD = new SqlCommand(string.Format("SELECT * FROM Character WHERE AID={0} AND CharNum={1}", nAID, nIndex), m_sqlConnection))
                {
                    using (SqlDataReader sqlDR = sqlCMD.ExecuteReader())
                    {
                        if (!sqlDR.Read())
                            return false;
                        charInfo.nCID = Convert.ToInt32(sqlDR["CID"]);
                        charInfo.nCLID = 0;//Convert.ToInt32(sqlDR["CLID"]);
                        charInfo.szName = Convert.ToString(sqlDR["Name"]);
                        charInfo.nLevel = Convert.ToByte(sqlDR["Level"]);
                        charInfo.nSex = Convert.ToByte(sqlDR["Sex"]);
                        charInfo.nHair = Convert.ToByte(sqlDR["Hair"]);
                        charInfo.nFace = Convert.ToByte(sqlDR["Face"]);
                        charInfo.nXP = Convert.ToInt32(sqlDR["XP"]);
                        charInfo.nBP = Convert.ToInt32(sqlDR["BP"]);
                        charInfo.fBonusRate = 0.0f;
                        charInfo.nPrize = 0;
                        charInfo.nFR = 0;
                        charInfo.nER = 0;
                        charInfo.nCR = 0;
                        charInfo.nWR = 0;
                        charInfo.nSafeFalls = 0;

                        ArrayList items = new ArrayList();
                        Execute("SELECT head_slot,chest_slot,hands_slot,legs_slot,Feet_slot,fingerl_slot,fingerr_slot,melee_slot,primary_slot,secondary_slot,custom1_slot,custom2_slot FROM Character WHERE CID=" + charInfo.nCID, items);
                        for (int i = 0; i < 12; i++)
                        {
                            charInfo.nEquippedItems[i] = new Item();
                            charInfo.nEquippedItems[i].nItemCID = Convert.ToInt32(items[i]);
                        }
                        sqlCMD.CommandText = "SELECT ItemID,CIID,RentHourPeriod FROM CharacterItem WHERE CID=" + charInfo.nCID;
                        sqlDR.Close();
                        using (SqlDataReader sDR = sqlCMD.ExecuteReader())
                        {
                            while (sDR.Read())
                            {
                                Item nItem = new Item();
                                nItem.nItemID = Convert.ToInt32(sDR["itemid"]);
                                nItem.nItemCID = Convert.ToInt32(sDR["CIID"]);
                                nItem.nRentHour = Convert.ToInt32(sDR.IsDBNull(2) ? 0 : sDR["RentHourPeriod"]);
                                charInfo.nItems.Add(nItem);
                            }
                        }
                        for (int i = 0; i < 12; i++)
                        {
                            Item item = charInfo.nItems.Find(ii => ii.nItemCID == charInfo.nEquippedItems[i].nItemCID);
                            if (item == null)
                                charInfo.nEquippedItems[i].nItemID = 0;
                            else
                                charInfo.nEquippedItems[i].nItemID = item.nItemID;
                        }
                        return true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void UnloadCharacter()
 {
     if (mChannel != null)
         ChannelMgr.Leave(this);
     mClientFlags = PacketFlags.Login;
     mPlace = MMatchPlace.Outside;
     mCharacter = new MTD_CharInfo();
 }