Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. bool ClanSys::AskJoinPledgePacket(CUserSocket *pSocket, const unsigned char* packet)
  2. {
  3. if(pSocket->ValidUserSocket())
  4. {
  5. if(User *pUser = pSocket->GetUser())
  6. {
  7. CPledge *pPledge = pUser->GetPledge();
  8. if(pPledge && pPledge->pSD && !pUser->pSD->bHide)
  9. {
  10. if(CheckPrivilege(pUser->pSD->n64_PledgePower1, JOIN_CLAN) || pUser->pSD->nIsPledgeLeader > 0)
  11. {
  12. if(!(pPledge->pSD->nState == 3))
  13. {
  14. if(pPledge->CanAcceptNewMember())
  15. {
  16. if(pPledge->IsWorkingWithAnotherClan(30))
  17. {
  18. UINT nTargetID, nPledgeType;
  19. packet = Disassemble(packet, "d", &nTargetID, &nPledgeType);
  20.  
  21. if(pPledge->CanJoin(nPledgeType = CPledge::MAIN_CLAN))
  22. {
  23. User *pTarget = User::GetUserBySID(&nTargetID);
  24. if(pTarget->ValidUser())
  25. {
  26. if(pTarget->pSD->nPledgeID == 0)
  27. {
  28. if(nPledgeType == -1) //Academy
  29. {
  30. int nClass = pTarget->pSD->nClass;
  31. if(pTarget->pSD->nLevel < 40)
  32. {
  33. if(CCategoryDataDB::IsInCategory(nClass, CCategoryDataDB::FIRST_CLASS_GROUP) || CCategoryDataDB::IsInCategory(nClass, CCategoryDataDB::SECOND_CLASS_GROUP))
  34. {
  35. //ok
  36. }else
  37. {
  38. pSocket->SendSystemMessage(1734);//To join a Clan Academy, characters must be Level 40 or below, not belong another clan and not yet completed their 2nd class transfer.
  39. return false;
  40. }
  41. }else
  42. {
  43. pSocket->SendSystemMessage(1734); //To join a Clan Academy, characters must be Level 40 or below, not belong another clan and not yet completed their 2nd class transfer.
  44. return false;
  45. }
  46. }
  47.  
  48. if(pTarget->CanJoinPledge())
  49. {
  50. if(L2Server::RequestInvite(0, pUser, pTarget, 30))
  51. {
  52. if(nPledgeType = CPledge::MAIN_CLAN)
  53. {
  54. //invite to main clan
  55. pTarget->GetSocket()->Send("cdcd", 0x34, pUser->nObjectID, pPledge->pSD->wszClanName, nPledgeType = CPledge::MAIN_CLAN);
  56. pTarget->pSD->nPledgeType = CPledge::MAIN_CLAN;
  57. }
  58. }else
  59. {
  60. pSocket->SendSystemMessage(0xA4); //You are waiting for another reply
  61. pSocket->Send("cd", 0x33, 0);
  62. }
  63. }else
  64. {
  65. pSocket->Send("cdddS", 0x64, 760, 1, 0, pUser->pSD->wszName); //$s1 cannot join the clan because one day has not yet passed since he/she left another clan.
  66. pSocket->Send("cd", 0x33, 0);
  67. }
  68. }else
  69. {
  70. pSocket->SendSystemMessage(152);//You have invited the wrong target.
  71. pSocket->Send("cd", 0x33, 0);
  72. }
  73. }else
  74. {
  75. pSocket->SendSystemMessage(152);//You have invited the wrong target.
  76. pSocket->Send("cd", 0x33, 0);
  77. }
  78. }else
  79. {
  80. if(nPledgeType = CPledge::MAIN_CLAN)
  81. pSocket->Send("cdddS", 0x64, 1835, 1, 0, pPledge->pSD->wszClanName); //Main clan is full
  82. else
  83. pSocket->SendSystemMessage(233); //Subpledge is full or doesnt exist
  84. pSocket->Send("cd", 0x33, 0);
  85. }
  86. }else
  87. {
  88. //pSocket->SendSystemMessage(8); //You are working with another clan.
  89. pSocket->SendSystemMessage(0xA4); //You are waiting for another reply.
  90. pSocket->Send("cd", 0x33, 0);
  91. }
  92. }else
  93. {
  94. pSocket->SendSystemMessage(231);//After a clan member is dismissed from a clan, the clan must wait at least a day before accepting a new member.
  95. pSocket->Send("cd", 0x33, 0);
  96. }
  97. }else
  98. {
  99. pSocket->SendSystemMessage(0x107);//You have already requested the dissolution of your clan.
  100. pSocket->Send("cd", 0x33, 0);
  101. }
  102. }else
  103. {
  104. pSocket->SendSystemMessage(794); //You are not authorized to do that.
  105. pSocket->Send("cd", 0x33, 0);
  106. }
  107. }else
  108. {
  109. pSocket->SendSystemMessage(794);//You are not authorized to do that.
  110. pSocket->Send("cd", 0x33, 0);
  111. }
  112. }
  113. }
  114. return false;
  115. }
  116. bool ClanSys::AnswerJoinPledgePacket(CUserSocket *pSocket, const unsigned char* packet)
  117. {
  118. if(pSocket->ValidUserSocket())
  119. {
  120. if(User *pUser = pSocket->GetUser())
  121. {
  122. int nAnswer;
  123. Disassemble(packet,"d", &nAnswer);
  124. CObjectSP ObjectSP;
  125. L2Server::GetInviter(&ObjectSP, pUser);
  126. User *pInviter = ObjectSP.pObject->GetUser();
  127. if(pInviter->ValidUser())
  128. {
  129. CPledge *pPledge = pInviter->GetPledge();
  130. if(pPledge)
  131. {
  132. if(nAnswer && pPledge->CanJoin(pUser->pSD->nPledgeType))
  133. {
  134. if(pUser->pSD->nPledgeID == 0)
  135. {
  136. g_DB.RequestUpdateUserPledge(pUser, pPledge, 1);
  137. L2Server::ResetInvite(pUser);
  138. }else
  139. {
  140. pInviter->GetSocket()->Send("cd", 0x33, 0);
  141. pPledge->nWaitingForReply = 0;
  142. L2Server::ResetInvite(pUser);
  143. }
  144. }else
  145. {
  146. L2Server::ResetInvite(pUser);
  147. pInviter->GetSocket()->Send("cd", 0x33, 0);
  148. pPledge->nWaitingForReply = 0;
  149. }
  150. }else
  151. {
  152. pInviter->GetSocket()->Send("cd", 0x33, 0);
  153. L2Server::ResetInvite(pUser);
  154. }
  155. }else
  156. {
  157. pSocket->SendSystemMessage(145);
  158. L2Server::ResetInvite(pUser);
  159. }
  160. }
  161. }
  162. return false;
  163. }