bool ClanSys::AskJoinPledgePacket(CUserSocket *pSocket, const unsigned char* packet)
{
if(pSocket->ValidUserSocket())
{
if(User *pUser = pSocket->GetUser())
{
CPledge *pPledge = pUser->GetPledge();
if(pPledge && pPledge->pSD && !pUser->pSD->bHide)
{
if(CheckPrivilege(pUser->pSD->n64_PledgePower1, JOIN_CLAN) || pUser->pSD->nIsPledgeLeader > 0)
{
if(!(pPledge->pSD->nState == 3))
{
if(pPledge->CanAcceptNewMember())
{
if(pPledge->IsWorkingWithAnotherClan(30))
{
UINT nTargetID, nPledgeType;
packet = Disassemble(packet, "d", &nTargetID, &nPledgeType);
if(pPledge->CanJoin(nPledgeType = CPledge::MAIN_CLAN))
{
User *pTarget = User::GetUserBySID(&nTargetID);
if(pTarget->ValidUser())
{
if(pTarget->pSD->nPledgeID == 0)
{
if(nPledgeType == -1) //Academy
{
int nClass = pTarget->pSD->nClass;
if(pTarget->pSD->nLevel < 40)
{
if(CCategoryDataDB::IsInCategory(nClass, CCategoryDataDB::FIRST_CLASS_GROUP) || CCategoryDataDB::IsInCategory(nClass, CCategoryDataDB::SECOND_CLASS_GROUP))
{
//ok
}else
{
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.
return false;
}
}else
{
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.
return false;
}
}
if(pTarget->CanJoinPledge())
{
if(L2Server::RequestInvite(0, pUser, pTarget, 30))
{
if(nPledgeType = CPledge::MAIN_CLAN)
{
//invite to main clan
pTarget->GetSocket()->Send("cdcd", 0x34, pUser->nObjectID, pPledge->pSD->wszClanName, nPledgeType = CPledge::MAIN_CLAN);
pTarget->pSD->nPledgeType = CPledge::MAIN_CLAN;
}
}else
{
pSocket->SendSystemMessage(0xA4); //You are waiting for another reply
pSocket->Send("cd", 0x33, 0);
}
}else
{
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.
pSocket->Send("cd", 0x33, 0);
}
}else
{
pSocket->SendSystemMessage(152);//You have invited the wrong target.
pSocket->Send("cd", 0x33, 0);
}
}else
{
pSocket->SendSystemMessage(152);//You have invited the wrong target.
pSocket->Send("cd", 0x33, 0);
}
}else
{
if(nPledgeType = CPledge::MAIN_CLAN)
pSocket->Send("cdddS", 0x64, 1835, 1, 0, pPledge->pSD->wszClanName); //Main clan is full
else
pSocket->SendSystemMessage(233); //Subpledge is full or doesnt exist
pSocket->Send("cd", 0x33, 0);
}
}else
{
//pSocket->SendSystemMessage(8); //You are working with another clan.
pSocket->SendSystemMessage(0xA4); //You are waiting for another reply.
pSocket->Send("cd", 0x33, 0);
}
}else
{
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.
pSocket->Send("cd", 0x33, 0);
}
}else
{
pSocket->SendSystemMessage(0x107);//You have already requested the dissolution of your clan.
pSocket->Send("cd", 0x33, 0);
}
}else
{
pSocket->SendSystemMessage(794); //You are not authorized to do that.
pSocket->Send("cd", 0x33, 0);
}
}else
{
pSocket->SendSystemMessage(794);//You are not authorized to do that.
pSocket->Send("cd", 0x33, 0);
}
}
}
return false;
}
bool ClanSys::AnswerJoinPledgePacket(CUserSocket *pSocket, const unsigned char* packet)
{
if(pSocket->ValidUserSocket())
{
if(User *pUser = pSocket->GetUser())
{
int nAnswer;
Disassemble(packet,"d", &nAnswer);
CObjectSP ObjectSP;
L2Server::GetInviter(&ObjectSP, pUser);
User *pInviter = ObjectSP.pObject->GetUser();
if(pInviter->ValidUser())
{
CPledge *pPledge = pInviter->GetPledge();
if(pPledge)
{
if(nAnswer && pPledge->CanJoin(pUser->pSD->nPledgeType))
{
if(pUser->pSD->nPledgeID == 0)
{
g_DB.RequestUpdateUserPledge(pUser, pPledge, 1);
L2Server::ResetInvite(pUser);
}else
{
pInviter->GetSocket()->Send("cd", 0x33, 0);
pPledge->nWaitingForReply = 0;
L2Server::ResetInvite(pUser);
}
}else
{
L2Server::ResetInvite(pUser);
pInviter->GetSocket()->Send("cd", 0x33, 0);
pPledge->nWaitingForReply = 0;
}
}else
{
pInviter->GetSocket()->Send("cd", 0x33, 0);
L2Server::ResetInvite(pUser);
}
}else
{
pSocket->SendSystemMessage(145);
L2Server::ResetInvite(pUser);
}
}
}
return false;
}