private static void LoadCharInfo(string charID, ref Packet result) { KODatabase db = new KODatabase(); var user = db.USERDATA.Where(u => u.strUserID == charID).First(); int nHair = 0; short sClass = 0; byte bRace = 0, bLevel = 0, bFace = 0, bZone = 0; string strItem = String.Empty; byte[] ItemArray = new byte[INVENTORY_TOTAL * 8];// = ToBytes(strItem); if (user != null) { result.SetString(user.strUserID); result.SetByte(user.Race); result.SetShort(user.Class); result.SetByte(user.Level); result.SetByte(user.Face); result.SetDword(user.HairRGB); result.SetByte(user.Zone); Packet item = new Packet(); item.append(user.strItem, user.strItem.Length); for (int i = 0; i < SLOT_MAX; i++) { int nItemID; short sDurability, sCount; nItemID = item.GetDWORD(); sDurability = item.GetShort(); sCount = item.GetShort(); if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(nItemID); result.SetShort(sDurability); } } } else { result.SetString(charID); result.SetByte(bRace); result.SetShort(sClass); result.SetByte(bLevel); result.SetByte(bFace); result.SetDword(nHair); result.SetByte(bZone); for (int i = 0; i < SLOT_MAX; i++) { if (i == HEAD || i == BREAST || i == SHOULDER || i == LEG || i == GLOVE || i == FOOT || i == RIGHTHAND || i == LEFTHAND) { result.SetDword(0); result.SetShort(0); } } } }
private static void ReqLetterRead(Packet pkt, User pUser) { Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER); Int32 nLetterID = pkt.GetDWORD(); String strMessage = String.Empty; result.SetByte(LETTER_READ); if (!DBAgent.ReadLetter(pUser.GetAccountID(), nLetterID, strMessage)) { result.SetByte(0); } else { result.SByte(); result.SetByte(1).SetDword(nLetterID).SetString(strMessage); } pUser.Send(result); }
public static bool LoadUserData(string AccountID, string strCharID, ref User pUser) { KODatabase db = new KODatabase(); try { USERDATA pData = db.USERDATA.Where(user => user.strUserID == strCharID).FirstOrDefault(); if (pData == null) { return(false); } pUser.m_bNation = pData.Nation; pUser.m_bRace = pData.Race; pUser.m_sClass = pData.Class; pUser.m_nHair = pData.HairRGB; pUser.m_bRank = pData.Rank; pUser.m_bTitle = pData.Title; pUser.m_bLevel = pData.Level; pUser.m_iExp = pData.Exp; pUser.m_iLoyalty = pData.Loyalty; pUser.m_bFace = pData.Face; pUser.m_bCity = (sbyte)pData.City; pUser.m_bKnights = pData.Knights; pUser.m_bFame = pData.Fame; pUser.m_sHp = pData.Hp; pUser.m_sMp = pData.Mp; pUser.m_sSp = pData.Sp; pUser.m_bStats[(int)StatType.STAT_STR] = pData.Strong; pUser.m_bStats[(int)StatType.STAT_STA] = pData.Sta; pUser.m_bStats[(int)StatType.STAT_DEX] = pData.Dex; pUser.m_bStats[(int)StatType.STAT_INT] = pData.Intel; pUser.m_bStats[(int)StatType.STAT_CHA] = pData.Cha; pUser.m_bAuthority = pData.Authority; pUser.m_sPoints = pData.Points; pUser.m_iGold = pData.Gold; pUser.m_bZone = pData.Zone; pUser.m_sBind = (long)pData.Bind; pUser.m_curx = (float)(pData.PX / 100.0f); pUser.m_curz = (float)(pData.PZ / 100.0f); pUser.m_cury = (float)(pData.PY / 100.0f); pUser.m_oldx = pUser.m_curx; pUser.m_oldy = pUser.m_cury; pUser.m_oldz = pUser.m_curz; pUser.m_dwTime = pData.dwTime; pUser.m_bstrSkill = pData.strSkill.ToCharArray(); Packet itemBuffer = new Packet(pData.strItem); Packet serialBuffer = new Packet(pData.strSerial); Packet itemTimeBuffer = new Packet(pData.strItemTime); for (int i = 0; i < INVENTORY_TOTAL; i++) { Int64 nSerialNum; Int32 nItemID; Int16 sDurability, sCount, nRentalTime; Int32 nItemTime; nItemID = itemBuffer.GetDWORD(); sDurability = itemBuffer.GetShort(); sCount = itemBuffer.GetShort(); nSerialNum = serialBuffer.GetInt64(); nItemTime = itemTimeBuffer.GetDWORD(); nRentalTime = itemTimeBuffer.GetShort(); _ITEM_DATA pItem = new _ITEM_DATA(); pItem.nNum = nItemID; pItem.sCount = sCount; pItem.sDuration = sDurability; pItem.nSerialNum = nSerialNum; pItem.nExpirationTime = nItemTime; pItem.sRemainingRentalTime = nRentalTime; pUser.m_sItemArray[i] = pItem; } return(true); } catch (Exception ex) { Debug.WriteLine("Karakter bilgileri alınırken özel durum oluştu : " + ex.Message); return(false); } }
public static bool LoadUserData(string AccountID, string strCharID, ref User pUser) { KODatabase db = new KODatabase(); try { USERDATA pData = db.USERDATA.Where(user => user.strUserID == strCharID).FirstOrDefault(); if (pData == null) return false; pUser.m_bNation = pData.Nation; pUser.m_bRace = pData.Race ; pUser.m_sClass = pData.Class ; pUser.m_nHair = pData.HairRGB; pUser.m_bRank = pData.Rank ; pUser.m_bTitle = pData.Title ; pUser.m_bLevel = pData.Level ; pUser.m_iExp = pData.Exp ; pUser.m_iLoyalty= pData.Loyalty; pUser.m_bFace = pData.Face ; pUser.m_bCity = (sbyte)pData.City ; pUser.m_bKnights= pData.Knights; pUser.m_bFame = pData.Fame ; pUser.m_sHp = pData.Hp ; pUser.m_sMp = pData.Mp ; pUser.m_sSp = pData.Sp ; pUser.m_bStats[(int)StatType.STAT_STR] = pData.Strong; pUser.m_bStats[(int)StatType.STAT_STA] = pData.Sta; pUser.m_bStats[(int)StatType.STAT_DEX] = pData.Dex; pUser.m_bStats[(int)StatType.STAT_INT] = pData.Intel; pUser.m_bStats[(int)StatType.STAT_CHA] = pData.Cha; pUser.m_bAuthority= pData.Authority; pUser.m_sPoints = pData.Points ; pUser.m_iGold = pData.Gold ; pUser.m_bZone = pData.Zone ; pUser.m_sBind = (long)pData.Bind; pUser.m_curx = (float)(pData.PX / 100.0f); pUser.m_curz = (float)(pData.PZ / 100.0f); pUser.m_cury = (float)(pData.PY / 100.0f); pUser.m_oldx = pUser.m_curx; pUser.m_oldy = pUser.m_cury; pUser.m_oldz = pUser.m_curz; pUser.m_dwTime = pData.dwTime; pUser.m_bstrSkill = pData.strSkill.ToCharArray(); Packet itemBuffer = new Packet(pData.strItem); Packet serialBuffer = new Packet(pData.strSerial); Packet itemTimeBuffer = new Packet(pData.strItemTime); for (int i = 0; i < INVENTORY_TOTAL; i++) { Int64 nSerialNum; Int32 nItemID; Int16 sDurability, sCount, nRentalTime; Int32 nItemTime; nItemID = itemBuffer.GetDWORD(); sDurability = itemBuffer.GetShort(); sCount = itemBuffer.GetShort(); nSerialNum = serialBuffer.GetInt64(); nItemTime = itemTimeBuffer.GetDWORD(); nRentalTime = itemTimeBuffer.GetShort(); _ITEM_DATA pItem = new _ITEM_DATA(); pItem.nNum = nItemID; pItem.sCount = sCount; pItem.sDuration = sDurability; pItem.nSerialNum = nSerialNum; pItem.nExpirationTime = nItemTime; pItem.sRemainingRentalTime = nRentalTime; pUser.m_sItemArray[i] = pItem; } return true; } catch(Exception ex) { Debug.WriteLine("Karakter bilgileri alınırken özel durum oluştu : " + ex.Message); return false; } }
private static void ReqLetterRead(Packet pkt, User pUser) { Packet result = new Packet(WIZ_SHOPPING_MALL, STORE_LETTER); Int32 nLetterID = pkt.GetDWORD(); String strMessage = String.Empty; result.SetByte(LETTER_READ); if (!DBAgent.ReadLetter(pUser.GetAccountID(), nLetterID, strMessage)) result.SetByte(0); else { result.SByte(); result.SetByte(1).SetDword(nLetterID).SetString(strMessage); } pUser.Send(result); }