Olá amiguinhos, hoje estarei postando um tutorial de como deixar seu gunz, pra criar clan com 2 jogadores, (Em todos os gunz precisam de 4 jogadores, e etc, mas seguindo esse tutorial, consegue fazer com 2 somente.)
Tutorial:
Vá na CSCommon da sua source, e abra o arquivo MAsyncDBJob.h :
Procure por:
class MAsyncDBJob_CreateClan : public MAsyncJob {
////////////////////////////////////////////////////////////////////////////////////////////////////
class MAsyncDBJob_CreateClan : public MAsyncJob {
protected:
MUID m_uidMaster;
MUID m_uidMember1;
// MUID m_uidMember2;
// MUID m_uidMember3;
// MUID m_uidMember4;
protected: // Input Argument
char m_szClanName[256];
int m_nMasterCID;
int m_nMember1CID;
// int m_nMember2CID;
// int m_nMember3CID;
// int m_nMember4CID;
protected: // Output Result
bool m_bDBResult;
int m_nNewCLID;
public:
MAsyncDBJob_CreateClan(const MUID& uidOwne) : MAsyncJob(MASYNCJOB_CREATECLAN, uidOwne) ,
m_bDBResult(false),
m_nNewCLID(0)
{
}
virtual ~MAsyncDBJob_CreateClan() {}
bool Input(const TCHAR* szClanName,
const int nMasterCID,
const int nMember1CID,
// const int nMember2CID,
// const int nMember3CID,
// const int nMember4CID,
const MUID& uidMaster,
const MUID& uidMember1);
// const MUID& uidMember2,
// const MUID& uidMember3,
// const MUID& uidMember4);
virtual void Run(void* pContext);
bool GetDBResult() { return m_bDBResult; }
int GetNewCLID() { return m_nNewCLID; }
const MUID& GetMasterUID() { return m_uidMaster; }
const MUID& GetMember1UID() { return m_uidMember1; }
// const MUID& GetMember2UID() { return m_uidMember2; }
// const MUID& GetMember3UID() { return m_uidMember3; }
// const MUID& GetMember4UID() { return m_uidMember4; }
const char* GetClanName() { return m_szClanName; }
};
////////////////////////////
Agora, na MMatchGlobal.h;
Procure por:
#define CLAN_SPONSORS_COUNT 4 // Ŭ·£»ý¼º½Ã ÇÊ¿äÇÑ ¹ß±âÀÎ ¼ö
Troque por:
#define CLAN_SPONSORS_COUNT 1 // Ŭ·£»ý¼º½Ã ÇÊ¿äÇÑ ¹ß±âÀÎ ¼ö
Agora, na MMatchDBMgr.h;
Procure por:
bool CreateClan(const TCHAR* szClanName, const int nMasterCID, const int nMember1CID, const int nMember2CID,
const int nMember3CID, const int nMember4CID, bool* boutRet, int* noutNewCLID);
bool CreateClan(const TCHAR* szClanName, const int nMasterCID, const int nMember1CID, bool* boutRet, int* noutNewCLID);
Agora em MAsyncDBJob.cpp;
Procure por:
void MAsyncDBJob_CreateClan::Run(void* pContext)
Substitua toda a class por:
/////////////////////////////////////////////////////////////////////////////////////////////////
void MAsyncDBJob_CreateClan::Run(void* pContext)
{
MMatchDBMgr* pDBMgr = (MMatchDBMgr*)pContext;
if (!pDBMgr->CreateClan(m_szClanName,
m_nMasterCID,
m_nMember1CID,
// m_nMember2CID,
// m_nMember3CID,
// m_nMember4CID,
&m_bDBResult,
&m_nNewCLID))
{
SetResult(MASYNC_RESULT_FAILED);
return;
}
SetResult(MASYNC_RESULT_SUCCEED);
}
bool MAsyncDBJob_CreateClan::Input(const TCHAR* szClanName,
const int nMasterCID,
const int nMember1CID,
// const int nMember2CID,
// const int nMember3CID,
// const int nMember4CID,
const MUID& uidMaster,
const MUID& uidMember1)
// const MUID& uidMember2,
// const MUID& uidMember3,
// const MUID& uidMember4)
{
strcpy(m_szClanName, szClanName);
m_nMasterCID = nMasterCID;
m_nMember1CID = nMember1CID;
// m_nMember2CID = nMember2CID;
// m_nMember3CID = nMember3CID;
// m_nMember4CID = nMember4CID;
m_uidMaster = uidMaster;
m_uidMember1 = uidMember1;
// m_uidMember2 = uidMember2;
// m_uidMember3 = uidMember3;
// m_uidMember4 = uidMember4;
return true;
}
//////////////////////////////
Em MMatchDBMgr.cpp;
Procure por:
TCHAR g_szDB_CREATE_CLAN[] = _T("{CALL spCreateClan ('%s', %d, %d, %d, %d, %d)}");
Substitua por:
TCHAR g_szDB_CREATE_CLAN[] = _T("{CALL spCreateClan ('%s', %d, %d)}");
No mesmo arquivo, MMatchDBMgr.cpp;
Procure por:
bool MMatchDBMgr::CreateClan(const TCHAR* szClanName, const int nMasterCID, const int nMember1CID, const int nMember2CID,
const int nMember3CID, const int nMember4CID, bool* boutRet, int* noutNewCLID)
Substitua todo caso por:
bool MMatchDBMgr::CreateClan(const TCHAR* szClanName, const int nMasterCID, const int nMember1CID, bool* boutRet, int* noutNewCLID)
{
_STATUS_DB_START;
if (!CheckOpen()) return false;
CString strSQL;
strSQL.Format(g_szDB_CREATE_CLAN, szClanName, nMasterCID, nMember1CID);
CODBCRecordset rs(&m_DB);
bool bException = false;
try
{
rs.Open(strSQL, CRecordset::forwardOnly, CRecordset::readOnly);
}
catch(CDBException* e)
{
bException = true;
ExceptionHandler(strSQL, e);
return false;
*boutRet = false;
return false;
}
if ((rs.IsOpen() == FALSE) || (rs.GetRecordCount() <= 0) || (rs.IsBOF()==TRUE))
{
*boutRet = false;
return false;
}
*boutRet = rs.Field("Ret").AsBool();
*noutNewCLID = rs.Field("NewCLID").AsInt();
_STATUS_DB_END(35);
return true;
}
Agora em MMatchServer_Async.cpp;
Procure por:
_ASSERT(CLAN_SPONSORS_COUNT == 4);
pSponsorObjects[0] = GetObject(pJob->GetMember1UID());
pSponsorObjects[1] = GetObject(pJob->GetMember2UID());
pSponsorObjects[2] = GetObject(pJob->GetMember3UID());
pSponsorObjects[3] = GetObject(pJob->GetMember4UID());
Substitua por:
_ASSERT(CLAN_SPONSORS_COUNT == 1);
pSponsorObjects[0] = GetObject(pJob->GetMember1UID());
//pSponsorObjects[1] = GetObject(pJob->GetMember2UID());
//pSponsorObjects[2] = GetObject(pJob->GetMember3UID());
//pSponsorObjects[3] = GetObject(pJob->GetMember4UID());
Em MMatchServer_Clan.cpp ;
Procure por:
if (CLAN_SPONSORS_COUNT == 4)
Substitua toda a "if" por:
if (CLAN_SPONSORS_COUNT == 1)
{
MAsyncDBJob_CreateClan* pNewJob = new MAsyncDBJob_CreateClan(uidPlayer);
pNewJob->Input(szClanName,
nMasterCID,
nMemberCID[0],
// nMemberCID[1],
// nMemberCID[2],
// nMemberCID[3],
pMasterObject->GetUID(),
pSponsorObjects[0]->GetUID());
// pSponsorObjects[1]->GetUID());
// pSponsorObjects[2]->GetUID(),
// pSponsorObjects[3]->GetUID());
// PostAsyncJob(pNewJob);
pMasterObject->m_DBJobQ.DBJobQ.push_back( pNewJob );
}
Em MSharedCommandTable.cpp;
Procure por:
C(MC_MATCH_CLAN_REQUEST_AGREED_CREATE_CLAN, "Match.Clan.RequestAgreedCreateClan", "Request Agreed Create Clan", MCDT_MACHINE2MACHINE)
Substitua tudo por:
C(MC_MATCH_CLAN_REQUEST_AGREED_CREATE_CLAN, "Match.Clan.RequestAgreedCreateClan", "Request Agreed Create Clan", MCDT_MACHINE2MACHINE)
P(MPT_UID, "uidChar") // ¿äûÇÑ Ä³¸¯ÅÍ UID
P(MPT_STR, "ClanName") // »ý¼ºÇÒ Å¬·£ À̸§
P(MPT_STR, "Member1CharName") // ¹ß±âÀΠij¸¯ÅÍ À̸§
// P(MPT_STR, "Member2CharName") // ¹ß±âÀΠij¸¯ÅÍ À̸§
// P(MPT_STR, "Member3CharName") // ¹ß±âÀΠij¸¯ÅÍ À̸§
// P(MPT_STR, "Member4CharName") // ¹ß±âÀΠij¸¯ÅÍ À̸§
Agora, na sua source, vá na pasta Gunz (Se não me engano, é Stable/Gunz), procure por
ZPost.h
Procure por:
inline void ZPostRequestCreateClan(const MUID& uidChar, const int nRequestID, char* szClanName,
Substitua tudo por:
inline void ZPostRequestCreateClan(const MUID& uidChar, const int nRequestID, char* szClanName,
char** ppMemberCharNames, int nMemberCharNamesCount)
{
if (nMemberCharNamesCount != CLAN_SPONSORS_COUNT) return;
ZPOSTCMD4(MC_MATCH_CLAN_REQUEST_CREATE_CLAN, MCmdParamUID(uidChar), MCmdParamInt(nRequestID), MCmdParamStr(szClanName),
MCmdParamStr(ppMemberCharNames[0]));
}
Agora, salve tudo, abra seu SQL Server, e faça o seguinte:
Dê um duplo clique eu sua GunzDB, duplo clique em Programmability, e mais um duplo clique em StoredProcedures, e procure por spCreateClan :
Substitua tudo por:
USE [GunzDB]
GO
/****** Object: StoredProcedure [dbo].[spCreateClan] Script Date: 03/01/2013 10:15:41 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Ŭ·£ »ý¼ºÇϱâ
ALTER PROC [dbo].[spCreateClan]
@ClanName varchar(24),
@MasterCID int,
@Member1CID int
AS
DECLARE @NewCLID int
-- Ŭ·£À̸§ÀÌ Áߺ¹ÀÎÁö °Ë»çÇؾßÇÑ´Ù.
SELECT @NewCLID=CLID FROM Clan(NOLOCK) WHERE Name=@ClanName
IF @NewCLID IS NOT NULL
BEGIN
SELECT 0 AS Ret, 0 AS NewCLID
RETURN
END
DECLARE @CNT int
-- Ŭ·£¿øÀÌ ¸ðµÎ °¡ÀÔ °¡´ÉÇÑÁö °Ë»çÇؾßÇÑ´Ù.
SELECT @CNT = COUNT(*) FROM ClanMember cm(NOLOCK), Character c(NOLOCK) WHERE ((cm.CID=@MasterCID) OR (cm.CID=@Member1CID) ) AND cm.CID=c.CID AND c.DeleteFlag=0
IF @CNT != 0
BEGIN
SELECT 0 AS Ret, 0 AS NewCLID
RETURN
END
BEGIN TRAN
-- Ŭ·£ »ý¼º
INSERT INTO Clan (Name, MasterCID, RegDate) VALUES (@ClanName, @MasterCID, GETDATE())
IF 0 <> @@ERROR BEGIN
ROLLBACK TRAN
SELECT 0 AS Ret, 0 AS NewCLID
RETURN
END
SELECT @NewCLID = @@IDENTITY
IF (@NewCLID IS not NULL)
BEGIN
DECLARE @Err1 int
DECLARE @Err2 int
DECLARE @Err3 int
DECLARE @Err4 int
DECLARE @Err5 int
-- Ŭ·£¿ø °¡ÀÔ
INSERT INTO ClanMember (CLID, CID, Grade, RegDate) VALUES (@NewCLID, @MasterCID, 1, GETDATE())
SET @Err1 = @@ERROR
INSERT INTO ClanMember (CLID, CID, Grade, RegDate) VALUES (@NewCLID, @Member1CID, 9, GETDATE())
SET @Err2 = @@ERROR
IF (0 <> @Err1) OR (0 <> @Err2) BEGIN
ROLLBACK TRAN
SELECT 0 AS Ret, 0 AS NewCLID
RETURN
END
END
COMMIT TRAN
-- ¸¶½ºÅÍ ¹Ù¿îƼ »èÁ¦
--UPDATE Character SET BP=BP-1000 WHERE CID=@MasterCID
SELECT 1 AS Ret, @NewCLID AS NewCLID
0 comentários:
Postar um comentário