Code:
CDetour ZGameClient__OnCommandDet;
CDetour ZCharacter__OnDamagedDetour;
CDetour ZMyCharacter__OnDamagedDetour;
const int PacketResponses[] = { 0x12F, 0x51B, 0x516, 0x517, 0x3F9, 0x5A2};
CDetour MAddSharedCommandTableDet;
void MAddSharedCommandTableHook (MCommandManager* pCommandManager, int nSharedType)
{
auto shotPacket = new MCommandDesc(0x3F9, "", "", 1);
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_INT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_FLOAT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_FLOAT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_FLOAT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_INT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_INT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_FLOAT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_FLOAT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_INT, ""));
shotPacket->AddParamDesc(new MCommandParameterDesc(MPT_INT, ""));
pCommandManager->AddCommandDesc(shotPacket);
//! Ban Request
{
MCommandDesc* pBanDesc = new MCommandDesc(0x1337, "", "", 1);
pBanDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pBanDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pCommandManager->AddCommandDesc(pBanDesc);
}
//! DC Request
{
MCommandDesc* pDCDesc = new MCommandDesc(0x1338, "", "", 1);
pDCDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pDCDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pCommandManager->AddCommandDesc(pDCDesc);
}
//! Mute Request
{
MCommandDesc* pMuteDesc = new MCommandDesc(0x1339, "", "", 1);
pMuteDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pMuteDesc->AddParamDesc(new MCommandParameterDesc(MPT_STRING, ""));
pCommandManager->AddCommandDesc(pMuteDesc);
}
{
MCommandDesc* pAutoBanDesc = new MCommandDesc(0x133B, "", "", 1);
pCommandManager->AddCommandDesc(pAutoBanDesc);
}
auto gameInterface = ((DWORD* (__cdecl*)())ZGetGameInterfaceAddress)();
auto chat = ((gameInterface)+(0x380/sizeof(DWORD)));
auto cmdManager = (DWORD*)((chat)+(0x4/sizeof(DWORD)));
ZChatCmdManager__AddCommand(cmdManager, 0, "fps", UpdateFps, 0xf, 0, 0, false, "/fps 500", "Fps Updater");
ZChatCmdManager__AddCommand(cmdManager, 0, "listfps", ListFps, 0xf, 0, 0, false, "/listfps", "listfps");
ZChatCmdManager__AddCommand(cmdManager, 0, "texture", UpdateTextures, 0xf, 0, 0, false, "/texture", "textures");
}
bool __stdcall ZGameClient__OnCommandHook(MCommand* pCommand)
{
Log::GetInstance()->info((boost::format("Got packet: [%1%]") % pCommand->m_pCommandDesc->m_szName).str().c_str());
for (int i = 0; i < 7; ++i)
{
if(pCommand->m_pCommandDesc->m_nCommandId == PacketResponses[i] && pCommand->m_uidSender.uidHigh != 2)
{
ZGameClient__OnCommandDet.Ret(FALSE);
Log::GetInstance()->error((boost::format("Invalid packet response: [%1%] recieved from %2%") % pCommand->m_pCommandDesc->m_szName % pCommand->m_uidSender.uidHigh).str().c_str());
return true;
}
}
if (pCommand->m_pCommandDesc->m_nCommandId == 0x2744)
{
int nId = 0;
char szMsg[512];
pCommand->GetParameter(szMsg, 1, MPT_STRING, 512);
if(strlen(szMsg) > 200)
{
ZGameClient__OnCommandDet.Ret(false);
return false;
}
}
if (pCommand->m_pCommandDesc->m_nCommandId == 0x3F9)
{
ZGameClient__OnCommandDet.Ret(false);
MUID uidPlayer;
float x,y,z,damage,ratio;
int ztype,wtype,mtype;
uidPlayer.uidLow = 0;
pCommand->GetParameter(&uidPlayer.uidHigh, 0, MPT_INT, -1);
if (pCommand->m_uidSender.uidHigh != GetMe().uidHigh)
{
MUID uidFrom;
uidFrom.uidLow = 0;
pCommand->GetParameter(&x, 1, MPT_FLOAT, -1);
pCommand->GetParameter(&y, 2, MPT_FLOAT, -1);
pCommand->GetParameter(&z, 3, MPT_FLOAT, -1);
pCommand->GetParameter(&ztype, 4, MPT_INT, -1);
pCommand->GetParameter(&wtype, 5, MPT_INT, -1);
pCommand->GetParameter(&damage, 6, MPT_FLOAT, -1);
pCommand->GetParameter(&ratio, 7, MPT_FLOAT, -1);
pCommand->GetParameter(&mtype, 8, MPT_INT, -1);
pCommand->GetParameter(&uidFrom.uidHigh, 9, MPT_INT, -1);
D3DXVector3 pos;
pos.x = x;
pos.y = y;
pos.z = z;
if (damage > 150 || ratio > 2)
{
Log::GetInstance()->warning((boost::format("Player: [%2%] attempted to hack the anti-lead [%2% dmg]") % Find(pCommand->m_uidSender)->Name % damage).str().c_str());
ZPrint("Player: %s is attempting to hack the anti-lead!", Find(pCommand->m_uidSender)->Name);
damage = 0;
}
//ZCharacter__OnDamagedDetour.Remove();
if (Find(GetMe()) != NULL)
{
if (uidPlayer.uidHigh == GetMe().uidHigh)
{
MSTAGE_SETTING_NODE& pNode = ZGetGameClient()->GetStageSetting()->GetStageSettingNode();
if ((pNode.nGameType == 0 || pNode.nGameType == 2 || pNode.nGameType == 5 || pNode.nGameType == 6 || pNode.nGameType == 10) || (Find(GetMe())->IsTeam(Find(pCommand->m_uidSender)) && pNode.bTeamKillEnabled) || !Find(GetMe())->IsTeam(Find(pCommand->m_uidSender)))
{
Find(GetMe())->OnDamaged(Find(uidFrom), pos, ztype, wtype, damage, ratio, mtype);
}
}
}
}
}
return true;
}
void __stdcall ZMyCharacter__OnDamagedHook(ZCharacter* pAttacker,D3DXVECTOR3 srcPos,int ZDAMAGETYPE, int WeaponType,float fDamage,float fPiercingRation,int nMeleeType)
{
if(!strstr(ZGetGameClient()->CurrentChannel, "[LEAD]"))
{
MSTAGE_SETTING_NODE& pNode = ZGetGameClient()->GetStageSetting()->GetStageSettingNode();
if ((ZDAMAGETYPE == 5 && nMeleeType == -1) || pNode.nGameType == 8)
{
//! Massives.
ZMyCharacter__OnDamagedDetour.Ret(true);
return;
}
if(ZDAMAGETYPE != 1 && ZDAMAGETYPE != 2 && pNode.nGameType != 7 && pAttacker->GetUID().uidHigh != GetMe().uidHigh)
{
ZMyCharacter__OnDamagedDetour.Ret(false);
ZMyCharacter__OnDamagedDetour.Org(pAttacker, srcPos, ZDAMAGETYPE, WeaponType, 0, 0, nMeleeType);
}
else
{
ZMyCharacter__OnDamagedDetour.Ret(true);
}
}
else
{
ZMyCharacter__OnDamagedDetour.Ret(true);
}
}
void __stdcall ZCharacter__OnDamagedHook(ZCharacter* pAttacker,D3DXVECTOR3 srcPos,int ZDAMAGETYPE, int WeaponType,float fDamage,float fPiercingRation,int nMeleeType)
{
if(!strstr(ZGetGameClient()->CurrentChannel, "[LEAD]"))
{
auto pVictim = (ZCharacter*)ZCharacter__OnDamagedDetour.GetThisPtr();
if (ZDAMAGETYPE == 1)
{
//Don't lead melee.
return;
}
if (pAttacker == Find(GetMe()) && pVictim != Find(GetMe()))
{
MCommand* pCmd = MCommand::Create(0x3F9);
//pCmd->m_uidReceiver = pVictim->GetUID();
pCmd->AddParameter(new MCommandParameterInt(pVictim->GetUID().uidHigh));
pCmd->AddParameter(new MCommandParameterFloat(srcPos.x));
pCmd->AddParameter(new MCommandParameterFloat(srcPos.y));
pCmd->AddParameter(new MCommandParameterFloat(srcPos.z));
pCmd->AddParameter(new MCommandParameterInt(ZDAMAGETYPE));
pCmd->AddParameter(new MCommandParameterInt(WeaponType));
pCmd->AddParameter(new MCommandParameterFloat(fDamage));
pCmd->AddParameter(new MCommandParameterFloat(fPiercingRation));
pCmd->AddParameter(new MCommandParameterInt(nMeleeType));
pCmd->AddParameter(new MCommandParameterInt(0));
MCommand::Post(pCmd);
fDamage = 0;
}
}
}
who can help or private or in here