Advertisement
Guest User

Untitled

a guest
Sep 6th, 2020
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.38 KB | None | 0 0
  1. void renderOutStreamPlayerTags(void)
  2. {
  3.     DebugThread.push_trace_func(eDebugThread::DEBUG_THREAD_RENDER, "i am here 1");
  4.     // don't run in the menu
  5.     if (gta_menu_active())
  6.         return;
  7.  
  8.  
  9.     // Exit this function and enable samp nametags, if panic key
  10.     if (cheat_state->_generic.cheat_panic_enabled || !bemod->MegaESP.enabled)
  11.         return;
  12.  
  13.     if (!g_dwSAMP_Addr || !g_SAMP || !g_Players)
  14.         return;
  15.  
  16.     // don't run during certain samp events
  17.     if (g_dwSAMP_Addr && g_SAMP)
  18.     {
  19.         if (
  20.             // Scoreboard open?
  21.             (GetAsyncKeyState(VK_TAB) < 0 && set.d3dtext_score)
  22.             || g_Scoreboard->iIsEnabled
  23.             // F10 key down?
  24.             || GetAsyncKeyState(VK_F10) < 0
  25.             )
  26.             return;
  27.     }
  28.  
  29.     // don't run if the CGameSA doesn't exist
  30.     if (!pGameInterface)
  31.         return;
  32.  
  33.     // don't run if we don't exist
  34.     if (isBadPtr_GTA_pPed(pPedSelf))
  35.         return;
  36.  
  37.     // for tracking player states as we iterate through
  38.     bool    isPedESPCollided[SAMP_MAX_PLAYERS];
  39.     bool    isPedESPStairStacked[SAMP_MAX_PLAYERS];
  40.     memset(isPedESPCollided, false, sizeof(bool)* SAMP_MAX_PLAYERS);
  41.     memset(isPedESPStairStacked, true, sizeof(bool)* SAMP_MAX_PLAYERS);
  42.  
  43.     // alignment settings
  44.     int         ESP_tag_player_pixelOffsetY = -10;
  45.     float       ESP_tag_player_D3DBox_pixelOffsetX = -0.5f;
  46.     float       ESP_tag_player_D3DBox_pixelOffsetY = -0.5f;
  47.     float       ESP_tag_player_posOffsetZ = 1.0f;
  48.     float       ESP_tag_player_espHeight = 40.0f;
  49.     //float     ESP_tag_player_movementSpeed = 5.0f;
  50.  
  51.  
  52.     D3DXVECTOR3 poss, screenposs;
  53.     char        buf[256];
  54.  
  55.     actor_info * actor_self = actor_info_get(ACTOR_SELF, NULL);
  56.  
  57.  
  58.     if (!actor_self)
  59.         return;
  60.  
  61.     // get initial variables for peds streamed in
  62.     for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
  63.     {
  64.  
  65.         if (g_Players->iIsListed[iGTAID] != 1)
  66.             continue;
  67.  
  68.         if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  69.             continue;
  70.  
  71.         actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  72.  
  73.         if (actor)
  74.             continue;
  75.  
  76.         // get the player position in 2D
  77.         poss.x = bemod->MegaESP.player[iGTAID].pos[0];
  78.         poss.y = bemod->MegaESP.player[iGTAID].pos[1];
  79.         poss.z = bemod->MegaESP.player[iGTAID].pos[2] + ESP_tag_player_posOffsetZ;
  80.         CalcScreenCoors(&poss, &screenposs);
  81.  
  82.         // check if the iter is culled or not
  83.         if (screenposs.z < 1.f)
  84.         {
  85.             g_playerTagInfo2[iGTAID].tagOffsetY = 0.0f;
  86.             g_playerTagInfo2[iGTAID].isPastMaxDistance = true;
  87.             g_playerTagInfo2[iGTAID].draw = false;
  88.             continue;
  89.         }
  90.         g_playerTagInfo2[iGTAID].draw = true;
  91.  
  92.         g_playerTagInfo2[iGTAID].dist = vect3_dist(actor_self->base.matrix + 12, bemod->MegaESP.player[iGTAID].pos);
  93.         // global, set ESP position for tagOffsetY use
  94.         g_playerTagInfo2[iGTAID].tagPosition.fX = screenposs.x;
  95.         g_playerTagInfo2[iGTAID].tagPosition.fY = screenposs.y;
  96.         g_playerTagInfo2[iGTAID].tagPosition.fZ = screenposs.z;
  97.     }
  98.  
  99.  
  100.     // remove staircase problem
  101.     for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
  102.     {
  103.  
  104.         if (g_Players->iIsListed[iGTAID] != 1)
  105.             continue;
  106.  
  107.         if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  108.             continue;
  109.  
  110.         actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  111.  
  112.         if (actor)
  113.             continue;
  114.  
  115.         // filter out "ok" ESP
  116.         if (!g_playerTagInfo2[iGTAID].isStairStacked
  117.             && g_playerTagInfo2[iGTAID].tagOffsetY < 40.0f
  118.             )
  119.             continue;
  120.  
  121.         // detect stair stacking per frame if ESP isn't already stair stacked
  122.         if (!g_playerTagInfo2[iGTAID].isStairStacked)
  123.         {
  124.             // reset iterInner position
  125.             for (int iGTAID_Inner = 0; iGTAID_Inner < SAMP_MAX_PLAYERS; iGTAID_Inner++)
  126.             {
  127.  
  128.                 if (g_Players->iIsListed[iGTAID] != 1)
  129.                     continue;
  130.  
  131.                 if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  132.                     continue;
  133.  
  134.                 actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  135.  
  136.                 if (actor)
  137.                     continue;
  138.  
  139.                 // ignore if it's us or isPastMaxDistance
  140.                 if (iGTAID_Inner == iGTAID)
  141.                     continue;
  142.  
  143.                 // test to see who comes out on top
  144.                 if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
  145.                     &&   abs((g_playerTagInfo2[iGTAID].tagPosition.fY - (g_playerTagInfo2[iGTAID].tagOffsetY / 2.0f)) - (g_playerTagInfo2[iGTAID_Inner].tagPosition.fY - g_playerTagInfo2[iGTAID_Inner].tagOffsetY)) <= ESP_tag_player_espHeight)
  146.                 {
  147.                     isPedESPStairStacked[iGTAID] = false;
  148.                 }
  149.             }
  150.  
  151.             // setup stair stack variables needed to un stack the ESP
  152.             if (isPedESPStairStacked[iGTAID])
  153.             {
  154.                 g_playerTagInfo2[iGTAID].isStairStacked = true;
  155.                 g_playerTagInfo2[iGTAID].stairStackedOffset = g_playerTagInfo2[iGTAID].tagOffsetY / 2.0f;
  156.             }
  157.         }   // end inner while - detect stair stacking
  158.  
  159.         // lower the offsets for stair stacked ESP
  160.         // and turn off stack status of ESP that reaches the "available" offset
  161.         if (g_playerTagInfo2[iGTAID].isStairStacked)
  162.         {
  163.             g_playerTagInfo2[iGTAID].tagOffsetY -= 5.0f;
  164.             g_playerTagInfo2[iGTAID].stairStackedOffset -= 5.0f;
  165.             if (g_playerTagInfo2[iGTAID].stairStackedOffset < 5.0f)
  166.             {
  167.                 g_playerTagInfo2[iGTAID].stairStackedOffset = 0.0f;
  168.                 g_playerTagInfo2[iGTAID].isStairStacked = false;
  169.             }
  170.         }
  171.     }       // end outer while - remove staircase problem
  172.  
  173.  
  174.     DebugThread.push_trace_func(eDebugThread::DEBUG_THREAD_RENDER, "i am here 3");
  175.     for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
  176.     {
  177.  
  178.         if (g_Players->iIsListed[iGTAID] != 1)
  179.             continue;
  180.  
  181.         if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  182.             continue;
  183.  
  184.         actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  185.  
  186.         if (actor)
  187.             continue;
  188.  
  189.         // we isPastMaxDistance or stairstacked, move along
  190.         if (g_playerTagInfo2[iGTAID].isStairStacked)
  191.             continue;
  192.  
  193.         for (int iGTAID_Inner = 0; iGTAID_Inner < SAMP_MAX_PLAYERS; iGTAID_Inner++)
  194.         {
  195.  
  196.             if (g_Players->iIsListed[iGTAID] != 1)
  197.                 continue;
  198.  
  199.             if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  200.                 continue;
  201.  
  202.             actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  203.  
  204.             if (actor)
  205.                 continue;
  206.  
  207.             // filter out isPastMaxDistance, stairstacked, and same Ped
  208.             if (g_playerTagInfo2[iGTAID_Inner].isStairStacked
  209.                 || iGTAID == iGTAID_Inner) continue;
  210.  
  211.             // player is within range, figure out if there's collision
  212.             if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
  213.                 &&   abs((g_playerTagInfo2[iGTAID].tagPosition.fY - g_playerTagInfo2[iGTAID].tagOffsetY) - (
  214.                 g_playerTagInfo2[iGTAID_Inner].tagPosition.fY - g_playerTagInfo2[iGTAID_Inner].tagOffsetY)) <= ESP_tag_player_espHeight)
  215.             {
  216.                 // collision, figure out who gets to stay
  217.                 if (g_playerTagInfo2[iGTAID].tagPosition.fZ < g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
  218.                 {
  219.                     // playerID "g_pTI_i" is farther, it should move up
  220.                     g_playerTagInfo2[iGTAID_Inner].tagOffsetY += 5.0f;
  221.                     isPedESPCollided[iGTAID_Inner] = true;
  222.                 }
  223.                 else if (g_playerTagInfo2[iGTAID].tagPosition.fZ > g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
  224.                 {
  225.                     // playerID "i" is farther, it should move up
  226.                     // we should only need normal upward movement here
  227.                     g_playerTagInfo2[iGTAID].tagOffsetY += 5.0f;
  228.                     isPedESPCollided[iGTAID] = true;
  229.                 }
  230.                 else
  231.                 {
  232.                     // both playerIDs are the same position @_@ so prefer the lower ID#
  233.                     if (iGTAID < iGTAID_Inner)
  234.                     {
  235.                         g_playerTagInfo2[iGTAID_Inner].tagOffsetY += 5.0f;
  236.                         isPedESPCollided[iGTAID_Inner] = true;
  237.                     }
  238.                     else
  239.                     {
  240.                         g_playerTagInfo2[iGTAID].tagOffsetY += 5.0f;
  241.                         isPedESPCollided[iGTAID] = true;
  242.                     }
  243.                 }
  244.             }
  245.  
  246.             // are we jigglin?  everybody likes ta jiggle.
  247.             if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
  248.                 && abs(
  249.                 (g_playerTagInfo2[iGTAID].tagPosition.fY - g_playerTagInfo2[iGTAID].tagOffsetY)
  250.                 - (g_playerTagInfo2[iGTAID_Inner].tagPosition.fY - g_playerTagInfo2[iGTAID_Inner].tagOffsetY)
  251.                 ) - 5.0f <= ESP_tag_player_espHeight
  252.                 )
  253.             {
  254.                 if (g_playerTagInfo2[iGTAID].tagPosition.fZ < g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
  255.                 {
  256.                     isPedESPCollided[iGTAID_Inner] = true;
  257.                 }
  258.                 else
  259.                 {
  260.                     isPedESPCollided[iGTAID] = true;
  261.                 }
  262.             }
  263.  
  264.  
  265.         }   // end inner while
  266.  
  267.         // return tagOffsetY to zero if needed
  268.         if (!isPedESPCollided[iGTAID])
  269.         {
  270.             if (g_playerTagInfo2[iGTAID].tagOffsetY >= 5.0f)
  271.             {
  272.                 g_playerTagInfo2[iGTAID].tagOffsetY -= 5.0f;
  273.             }
  274.             else
  275.             {
  276.                 g_playerTagInfo2[iGTAID].tagOffsetY = 0.0f;
  277.             }
  278.         }
  279.     }       // end outer while
  280.     DebugThread.push_trace_func(eDebugThread::DEBUG_THREAD_RENDER, "i am here 4");
  281.     float h, playerBaseY;
  282.     for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
  283.     {
  284.  
  285.         if (g_Players->iIsListed[iGTAID] != 1)
  286.             continue;
  287.  
  288.         if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
  289.             continue;
  290.  
  291.         actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
  292.  
  293.         if (actor)
  294.             continue;
  295.  
  296.         if (!g_playerTagInfo2[iGTAID].draw)
  297.             continue;
  298.  
  299.  
  300.  
  301.         DWORD tick = GetTickCount();
  302.  
  303.  
  304.         if (tick - bemod->MegaESP.player[iGTAID].dw_last_update > 5000 && bemod->smart_ESP.enabled)
  305.             continue;
  306.  
  307.         byte alpha = 0xff;
  308.  
  309.         byte alpha_distance = 0x5F;
  310.  
  311.         D3DCOLOR color_name = 0;
  312.  
  313.         D3DCOLOR
  314.         red = 0xFF,
  315.         green = 0xFF,
  316.         blue = 0xFF;
  317.         D3DCOLOR distance_color = 0xFFFFFFFF;
  318.  
  319.  
  320.         float dist = vect3_dist(bemod->MegaESP.player[iGTAID].pos,actor_info_get(ACTOR_SELF, NULL)->base.matrix + 12);
  321.  
  322.             if (dist < 500.0f)
  323.                 dist = 10.0f;
  324.  
  325.             if (dist > 2000.0f)
  326.                 dist = 2000.0f;
  327.  
  328.             alpha_distance = (2000.0f - dist) / 2000.0f*255.0f;
  329.  
  330.  
  331.         color_name = GetPlayerColor(iGTAID);
  332.  
  333.         alpha = GetPlayerAlpha(iGTAID);
  334.  
  335.         SetColorAlpha(color_name, alpha);
  336.  
  337.  
  338.         if (bemod->smart_ESP.enabled)
  339.             distance_color = color_name;
  340.  
  341.         SetColorAlpha(distance_color, alpha_distance);
  342.  
  343.  
  344.         playerBaseY = g_playerTagInfo2[iGTAID].tagPosition.fY -g_playerTagInfo2[iGTAID].tagOffsetY +ESP_tag_player_pixelOffsetY;
  345.  
  346.         //D3DCOLOR  color = D3DCOLOR_ARGB(0xFF, 0, 200, 0);
  347.  
  348.  
  349.  
  350.         CD3DFont * cFontDraw = pD3DFontFixed/*pD3DFont_sampStuff*/;
  351.         // this should also calculate the anti-aliasing top edge somehow
  352.         h = cFontDraw->DrawHeight() - 1;
  353.         _snprintf_s(buf, sizeof(buf)-1, "%s(%d)", getPlayerName(iGTAID), iGTAID);
  354.         cFontDraw->PrintShadow(g_playerTagInfo2[iGTAID].tagPosition.fX, playerBaseY - h,
  355.             color_name, buf);
  356.  
  357.  
  358.         _snprintf_s(buf, sizeof(buf)-1, "Distance %0.2f", g_playerTagInfo2[iGTAID].dist);
  359.         cFontDraw->PrintShadow(g_playerTagInfo2[iGTAID].tagPosition.fX, playerBaseY,
  360.             distance_color, buf);
  361.  
  362.  
  363.     }
  364.     // end render ESP tags
  365.     DebugThread.push_trace_func(eDebugThread::DEBUG_THREAD_RENDER, "i am here end");
  366. }
  367.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement