#pragma warning(disable:4409)
float GetZRot(uint32_t enemy)
{
if (enemy == 65535) return -0.0f;
float x1 = PEDSELF->GetPosition()->fX;
float y1 = PEDSELF->GetPosition()->fY;
float x2 = SF->getSAMP()->getPlayers()->pRemotePlayer[enemy]->pPlayerData->fOnFootPos[0];
float y2 = SF->getSAMP()->getPlayers()->pRemotePlayer[enemy]->pPlayerData->fOnFootPos[1];
float kx, ky;
float t, a;
kx = x2 - x1;
ky = y2 - y1;
if (kx == 0) kx = 0.00001f;
t = kx / ky;
if (t < 0) t = -t;
a = (float)(180 * atan((float)t) / M_PI);
if ((kx <= 0) && (ky <= 0)) a = 180 - a;
else if ((kx >= 0) && (ky >= 0)) a = 359.99999f - a;
else if ((kx >= 0) && (ky <= 0)) a = -(180 - a);
a = (a * M_PI) / 180.0f;
return a;
}
inline float GetDistance3D(float x1, float y1, float z1, float x2, float y2, float z2)
{
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + (z2 - z1) * (z2 - z1));
}
inline void SendTakeDamageRPC(uint32_t TargetID, unsigned int weapon_id, int damage)
{
BitStream bs;
bs.Write(true);
bs.Write(TargetID);
bs.Write((float)damage);
bs.Write(weapon_id);
bs.Write(3);
SF->getRakNet()->SendRPC(RPCEnumeration::RPC_GiveTakeDamage, &bs);
}
// переменная targetId должна содержать ид твоей жертвы
uint32_t targetId;
bool __stdcall HackMySync(stRakNetHookParams *hook)
{
if (hook->packetId == ID_PLAYER_SYNC && Enabled == true)
{
stOnFootData foot; byte packetID;
memset(&foot, 0, sizeof(stOnFootData));
hook->bitStream->ResetReadPointer();
hook->bitStream->Read((BYTE)packetID);
hook->bitStream->Read((PCHAR)&foot, sizeof(stOnFootData));
hook->bitStream->ResetReadPointer();
if (!SF->getSAMP()->getPlayers()->iIsListed[targetId]) return true;
if (!SF->getSAMP()->getPlayers()->IsPlayerDefined(targetId, true)) return true;
if (SF->getSAMP()->getPlayers()->pRemotePlayer[targetId]->pPlayerData->iAFKState == 2) return true;
if (SF->getSAMP()->getPlayers()->pRemotePlayer[targetId]->pPlayerData->bytePlayerState != PLAYER_STATE_ONFOOT) return true;
float dist[3], mdist[3];
for (short x = 0; x < 3; x++)
{
dist[x] = SF->getSAMP()->getPlayers()->pRemotePlayer[targetId]->pPlayerData->fOnFootPos[x];
mdist[x] = SF->getSAMP()->getPlayers()->pLocalPlayer->onFootData.fPosition[x];
}
if (GetDistance3D(dist[0], dist[1], dist[2], mdist[0], mdist[1], mdist[2]) > 30.0f) return true;
PEDSELF->SetTargetRotation(GetZRot(targetId));
for (short x = 0; x < 3; x++)
foot.fPosition[x] = SF->getSAMP()->getPlayers()->pRemotePlayer[targetId]->pPlayerData->fOnFootPos[x];
foot.fPosition[1] += 0.5f;
hook->bitStream->ResetWritePointer();
hook->bitStream->Write((BYTE)packetID);
hook->bitStream->Write((PCHAR)&foot, sizeof(stOnFootData));
SendTakeDamageRPC(targetId, 0, rand() % 3 + 1);
}
return true;
}