[C++ mod_sa] Bullet Tracers

dphome

Well-known member
Joined
Mar 21, 2020
Messages
475
Solutions
9
Reaction score
168
Location
Poland
ini.h
PHP:
int esp_bullets;
proxyIDirect3DDevice9.cpp
PHP:
void ESP_Bullets(void)
{
    if (set.esp_bullets)
    {
        traceLastFunc("ESP_Bullets()");
        if (!g_dwSAMP_Addr || !g_SAMP || !g_Players)
            return;
        if (gta_menu_active())
            return;
        if (cheat_state->_generic.cheat_panic_enabled)
            return;
        if (!pGameInterface)
            return;
        if (isBadPtr_GTA_pPed(pPedSelf))
            return;

        for (int i = 0; i < _countof(pBulletTracers); i++)
            pBulletTracers[i].update();
    }
}
proxyIDirect3DDevice9.h
PHP:
void ESP_Bullets(void);

class PlayerTrajectories
{
#pragma pack( push, 1 )
    struct stTrajectoryInfo
    {
        bool    enabled = false;
        DWORD    dwTick = 0;
        D3DXVECTOR3    begin;
        D3DXVECTOR3    end;
        D3DCOLOR color;
    };
#pragma pack( pop )
    int m_playerid;
    stTrajectoryInfo m_trajectories[20];
    const DWORD m_timeExists = 5000;
public:
    PlayerTrajectories(void);
    void add(int playerid, float origX, float origY, float origZ, float targetX, float targetY, float targetZ);
    void update(void);
    void clear(void);
};
extern PlayerTrajectories pBulletTracers[SAMP_MAX_PLAYERS];
cheat.cpp
PHP:
    // hack some SA:MP, shall we?
    if (g_SAMP && g_renderSAMP_initSAMPstructs)
    {
        sampMainCheat();
        ESP_Bullets();
    }
cheat_samp.cpp
PHP:
bool OnSendPacket(BitStream *parameters, PacketPriority priority, PacketReliability reliability, char orderingChannel)
{
    uint8_t packetId;
    parameters->Read(packetId);
    if (!isCheatPanicEnabled())
    {
        if (set.netPatchAssoc[packetId][OUTCOMING_PACKET] != nullptr && set.netPatchAssoc[packetId][OUTCOMING_PACKET]->enabled)
            return false;
    }
    if (packetId == ID_BULLET_SYNC && set.esp_bullets)
    {
        stBulletData data;
        ZeroMemory(&data, sizeof(data));
        byte packetId;

        parameters->ResetReadPointer();
        parameters->Read(packetId);
        parameters->Read((PCHAR)&data, sizeof(data));
        if ((int)data.fTarget[2] != 0)
        {
            pBulletTracers[g_Players->sLocalPlayerID].add(g_Players->sLocalPlayerID, data.fOrigin[0], data.fOrigin[1], data.fOrigin[2],
                data.fTarget[0], data.fTarget[1], data.fTarget[2]);
        }
        parameters->ResetWritePointer();
        parameters->Write(packetId);
        parameters->Write((PCHAR)&data, sizeof(stBulletData));
    }
    return true;
}

bool OnReceivePacket(Packet *p)
{
    if (p->data == nullptr || p->length == 0)
        return true;
    if (!isCheatPanicEnabled())
    {
        if (set.netPatchAssoc[p->data[0]][INCOMING_PACKET] != nullptr && set.netPatchAssoc[p->data[0]][INCOMING_PACKET]->enabled)
            return false;
    }
    if (p->data[0] == ID_MARKERS_SYNC) // packetId
    {
        BitStream    bs(p->data, p->length, false);
        int            iNumberOfPlayers = 0;
        uint16_t    playerID = uint16_t(-1);
        short        sPos[3] = { 0, 0, 0 };
        bool        bIsPlayerActive = false;

        bs.IgnoreBits(8);
        bs.Read(iNumberOfPlayers);
        if (iNumberOfPlayers < 0 || iNumberOfPlayers > SAMP_MAX_PLAYERS)
            return true;

        for (int i = 0; i < iNumberOfPlayers; i++)
        {
            bs.Read(playerID);
            bs.ReadCompressed(bIsPlayerActive);
            if (bIsPlayerActive == 0 || isBadSAMPPlayerID(playerID))
                continue;
            bs.Read(sPos);
            g_stStreamedOutInfo.iPlayerID[playerID] = playerID;
            g_stStreamedOutInfo.fPlayerPos[playerID][0] = sPos[0];
            g_stStreamedOutInfo.fPlayerPos[playerID][1] = sPos[1];
            g_stStreamedOutInfo.fPlayerPos[playerID][2] = sPos[2];
        }
    }
    if (p->data[0] == ID_BULLET_SYNC && set.esp_bullets)
    {
        BitStream    bs(p->data, p->length, false);
        stBulletData data;
        ZeroMemory(&data, sizeof(data));
        byte packetId;
        unsigned short senderId;

        bs.ResetReadPointer();
        bs.Read(packetId);
        bs.Read(senderId);
        bs.Read((PCHAR)&data, sizeof(data));

        pBulletTracers[senderId].add(senderId, data.fOrigin[0], data.fOrigin[1], data.fOrigin[2],
            data.fTarget[0], data.fTarget[1], data.fTarget[2]);

        bs.ResetWritePointer();
        bs.Write(packetId);
        bs.Write(senderId);
        bs.Write((PCHAR)&data, sizeof(stBulletData));
    }
    return true;
}
 
Top