void renderOutStreamPlayerTags(void)
{
// don't run in the menu
if (gta_menu_active())
return;
// Exit this function and enable samp nametags, if panic key
if (cheat_state->_generic.cheat_panic_enabled || !bemod->MegaESP.enabled)
return;
if (!g_dwSAMP_Addr || !g_SAMP || !g_Players)
return;
// don't run during certain samp events
if (g_dwSAMP_Addr && g_SAMP)
{
if (
// Scoreboard open?
(GetAsyncKeyState(VK_TAB) < 0 && set.d3dtext_score)
|| g_Scoreboard->iIsEnabled
// F10 key down?
|| GetAsyncKeyState(VK_F10) < 0
)
return;
}
// don't run if the CGameSA doesn't exist
if (!pGameInterface)
return;
// don't run if we don't exist
if (isBadPtr_GTA_pPed(pPedSelf))
return;
// for tracking player states as we iterate through
bool isPedESPCollided[SAMP_MAX_PLAYERS];
bool isPedESPStairStacked[SAMP_MAX_PLAYERS];
memset(isPedESPCollided, false, sizeof(bool)* SAMP_MAX_PLAYERS);
memset(isPedESPStairStacked, true, sizeof(bool)* SAMP_MAX_PLAYERS);
// alignment settings
int ESP_tag_player_pixelOffsetY = -10;
float ESP_tag_player_D3DBox_pixelOffsetX = -0.5f;
float ESP_tag_player_D3DBox_pixelOffsetY = -0.5f;
float ESP_tag_player_posOffsetZ = 1.0f;
float ESP_tag_player_espHeight = 40.0f;
//float ESP_tag_player_movementSpeed = 5.0f;
D3DXVECTOR3 poss, screenposs;
char buf[256];
actor_info * actor_self = actor_info_get(ACTOR_SELF, NULL);
if (!actor_self)
return;
// get initial variables for peds streamed in
for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
// get the player position in 2D
poss.x = bemod->MegaESP.player[iGTAID].pos[0];
poss.y = bemod->MegaESP.player[iGTAID].pos[1];
poss.z = bemod->MegaESP.player[iGTAID].pos[2] + ESP_tag_player_posOffsetZ;
CalcScreenCoors(&poss, &screenposs);
// check if the iter is culled or not
if (screenposs.z < 1.f)
{
g_playerTagInfo2[iGTAID].tagOffsetY = 0.0f;
g_playerTagInfo2[iGTAID].isPastMaxDistance = true;
g_playerTagInfo2[iGTAID].draw = false;
continue;
}
g_playerTagInfo2[iGTAID].draw = true;
g_playerTagInfo2[iGTAID].dist = vect3_dist(actor_self->base.matrix + 12, bemod->MegaESP.player[iGTAID].pos);
// global, set ESP position for tagOffsetY use
g_playerTagInfo2[iGTAID].tagPosition.fX = screenposs.x;
g_playerTagInfo2[iGTAID].tagPosition.fY = screenposs.y;
g_playerTagInfo2[iGTAID].tagPosition.fZ = screenposs.z;
}
// remove staircase problem
for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
// filter out "ok" ESP
if (!g_playerTagInfo2[iGTAID].isStairStacked
&& g_playerTagInfo2[iGTAID].tagOffsetY < 40.0f
)
continue;
// detect stair stacking per frame if ESP isn't already stair stacked
if (!g_playerTagInfo2[iGTAID].isStairStacked)
{
// reset iterInner position
for (int iGTAID_Inner = 0; iGTAID_Inner < SAMP_MAX_PLAYERS; iGTAID_Inner++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
// ignore if it's us or isPastMaxDistance
if (iGTAID_Inner == iGTAID)
continue;
// test to see who comes out on top
if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
&& 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)
{
isPedESPStairStacked[iGTAID] = false;
}
}
// setup stair stack variables needed to un stack the ESP
if (isPedESPStairStacked[iGTAID])
{
g_playerTagInfo2[iGTAID].isStairStacked = true;
g_playerTagInfo2[iGTAID].stairStackedOffset = g_playerTagInfo2[iGTAID].tagOffsetY / 2.0f;
}
} // end inner while - detect stair stacking
// lower the offsets for stair stacked ESP
// and turn off stack status of ESP that reaches the "available" offset
if (g_playerTagInfo2[iGTAID].isStairStacked)
{
g_playerTagInfo2[iGTAID].tagOffsetY -= 5.0f;
g_playerTagInfo2[iGTAID].stairStackedOffset -= 5.0f;
if (g_playerTagInfo2[iGTAID].stairStackedOffset < 5.0f)
{
g_playerTagInfo2[iGTAID].stairStackedOffset = 0.0f;
g_playerTagInfo2[iGTAID].isStairStacked = false;
}
}
} // end outer while - remove staircase problem
for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
// we isPastMaxDistance or stairstacked, move along
if (g_playerTagInfo2[iGTAID].isStairStacked)
continue;
for (int iGTAID_Inner = 0; iGTAID_Inner < SAMP_MAX_PLAYERS; iGTAID_Inner++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
// filter out isPastMaxDistance, stairstacked, and same Ped
if (g_playerTagInfo2[iGTAID_Inner].isStairStacked
|| iGTAID == iGTAID_Inner) continue;
// player is within range, figure out if there's collision
if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
&& abs((g_playerTagInfo2[iGTAID].tagPosition.fY - g_playerTagInfo2[iGTAID].tagOffsetY) - (
g_playerTagInfo2[iGTAID_Inner].tagPosition.fY - g_playerTagInfo2[iGTAID_Inner].tagOffsetY)) <= ESP_tag_player_espHeight)
{
// collision, figure out who gets to stay
if (g_playerTagInfo2[iGTAID].tagPosition.fZ < g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
{
// playerID "g_pTI_i" is farther, it should move up
g_playerTagInfo2[iGTAID_Inner].tagOffsetY += 5.0f;
isPedESPCollided[iGTAID_Inner] = true;
}
else if (g_playerTagInfo2[iGTAID].tagPosition.fZ > g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
{
// playerID "i" is farther, it should move up
// we should only need normal upward movement here
g_playerTagInfo2[iGTAID].tagOffsetY += 5.0f;
isPedESPCollided[iGTAID] = true;
}
else
{
// both playerIDs are the same position @_@ so prefer the lower ID#
if (iGTAID < iGTAID_Inner)
{
g_playerTagInfo2[iGTAID_Inner].tagOffsetY += 5.0f;
isPedESPCollided[iGTAID_Inner] = true;
}
else
{
g_playerTagInfo2[iGTAID].tagOffsetY += 5.0f;
isPedESPCollided[iGTAID] = true;
}
}
}
// are we jigglin? everybody likes ta jiggle.
if (abs(g_playerTagInfo2[iGTAID].tagPosition.fX - g_playerTagInfo2[iGTAID_Inner].tagPosition.fX) <= 100.0f
&& abs(
(g_playerTagInfo2[iGTAID].tagPosition.fY - g_playerTagInfo2[iGTAID].tagOffsetY)
- (g_playerTagInfo2[iGTAID_Inner].tagPosition.fY - g_playerTagInfo2[iGTAID_Inner].tagOffsetY)
) - 5.0f <= ESP_tag_player_espHeight
)
{
if (g_playerTagInfo2[iGTAID].tagPosition.fZ < g_playerTagInfo2[iGTAID_Inner].tagPosition.fZ)
{
isPedESPCollided[iGTAID_Inner] = true;
}
else
{
isPedESPCollided[iGTAID] = true;
}
}
} // end inner while
// return tagOffsetY to zero if needed
if (!isPedESPCollided[iGTAID])
{
if (g_playerTagInfo2[iGTAID].tagOffsetY >= 5.0f)
{
g_playerTagInfo2[iGTAID].tagOffsetY -= 5.0f;
}
else
{
g_playerTagInfo2[iGTAID].tagOffsetY = 0.0f;
}
}
} // end outer while
float h, playerBaseY;
for (int iGTAID = 0; iGTAID < SAMP_MAX_PLAYERS; iGTAID++)
{
if (g_Players->iIsListed[iGTAID] != 1)
continue;
if (vect3_near_zero(bemod->MegaESP.player[iGTAID].pos))
continue;
actor_info *actor = getGTAPedFromSAMPPlayerID(iGTAID);
if (actor)
continue;
if (!g_playerTagInfo2[iGTAID].draw)
continue;
DWORD tick = GetTickCount();
if (tick - bemod->MegaESP.player[iGTAID].dw_last_update > 5000 && bemod->smart_ESP.enabled)
continue;
byte alpha = 0xff;
byte alpha_distance = 0x5F;
D3DCOLOR color_name = 0;
D3DCOLOR
red = 0xFF,
green = 0xFF,
blue = 0xFF;
D3DCOLOR distance_color = 0xFFFFFFFF;
float dist = vect3_dist(bemod->MegaESP.player[iGTAID].pos,actor_info_get(ACTOR_SELF, NULL)->base.matrix + 12);
if (dist < 500.0f)
dist = 10.0f;
if (dist > 2000.0f)
dist = 2000.0f;
alpha_distance = (2000.0f - dist) / 2000.0f*255.0f;
color_name = GetPlayerColor(iGTAID);
alpha = GetPlayerAlpha(iGTAID);
SetColorAlpha(color_name, alpha);
if (bemod->smart_ESP.enabled)
distance_color = color_name;
SetColorAlpha(distance_color, alpha_distance);
playerBaseY = g_playerTagInfo2[iGTAID].tagPosition.fY -g_playerTagInfo2[iGTAID].tagOffsetY +ESP_tag_player_pixelOffsetY;
//D3DCOLOR color = D3DCOLOR_ARGB(0xFF, 0, 200, 0);
CD3DFont * cFontDraw = pD3DFontFixed/*pD3DFont_sampStuff*/;
// this should also calculate the anti-aliasing top edge somehow
h = cFontDraw->DrawHeight() - 1;
_snprintf_s(buf, sizeof(buf)-1, "%s(%d)", getPlayerName(iGTAID), iGTAID);
cFontDraw->PrintShadow(g_playerTagInfo2[iGTAID].tagPosition.fX, playerBaseY - h,
color_name, buf);
_snprintf_s(buf, sizeof(buf)-1, "Distance %0.2f", g_playerTagInfo2[iGTAID].dist);
cFontDraw->PrintShadow(g_playerTagInfo2[iGTAID].tagPosition.fX, playerBaseY,
distance_color, buf);
}
// end render ESP tags
}