NOTE: IF YOU HAVE A CLIENT HOOK YOU CAN DRAW THE ESP IN HUD_REDRAW OR HUD_FRAME IF YOU HAVE PROBS WITH GLBEGIN
First you should have TeamInfo hooked.
Second make a player info struct...IE: Code:
struct player_info{
};
Now you will need an int to store the team number and the entity info. Code:
struct player_info{
int team;
hud_player_info_t entinfo;
cl_entity_s *ent;
};
Make an array using vector Code:
std::vector<player_info> Player;
You will need the following for Getting a player by index Code:
int GetPlayerByIndex(int index)
{
for (int ax=0;ax<Player.size();ax++)
if (Player[ax].index == index) return ax;
return -1;
}
int GetPlayerByIndexX(int index)
{
player_info dummy;
int px = GetPlayerByIndex(index);
if (px == -1)
{
Player.push_back(dummy);
px = Player.size()-1;
Player[px].index = index;
try {
Player[px].ent = pEngfuncs->GetEntityByIndex(index);
pEngfuncs->pfnGetPlayerInfo(index, &Player[px].entinfo);
}
catch (...)
{}
Player[px].inpvs = 0;
}
return px;
}
Now, when TeamInfo is called Get the current player by index Code:
int px = GetPlayerByIndexX(eindex);
Then Check if teamtext is TERRORIST, or CT or UNASSIGNED or SPECTATOR
IE: Code:
const char * STR_TERROR = "TERRORIST";
const char * STR_CT = "CT";
const char * STR_UNASSIGNED = "UNASSIGNED";
const char * STR_SPECTATOR = "SPECTATOR";
if (!strcmpi (teamtext, STR_TERROR)) Player[px].team = 1;
else if (!strcmpi (teamtext, STR_CT)) Player[px].team = 2;
else if (!strcmpi (teamtext, STR_UNASSIGNED)) Player[px].team = 0;
else if (!strcmpi (teamtext, STR_SPECTATOR)) Player[px].team = 0;
else {
Player[px].team = -1;
}
Also at this point we can store the Player's Entity Info.
IE: Code:
pEngfuncs->pfnGetPlayerInfo(Player[px].ent->index, &Player[px].entinfo);
Create a CalcScreen bool...It should look like this: Code:
bool CalcScreen(float *origin,float *vecScreen)
{
int result = pEngfuncs->pTriAPI->WorldToScreen(origin,vecScreen);
if(vecScreen[0] < 1 && vecScreen[1] < 1 && vecScreen[0] > -1 && vecScreen[1] > -1 && !result)
{
vecScreen[0] = vecScreen[0] * pEngfuncs->GetWindowCenterX() + pEngfuncs->GetWindowCenterX();
vecScreen[1] = -vecScreen[1] * pEngfuncs->GetWindowCenterY() + pEngfuncs->GetWindowCenterY();
return true;
}
return false;
}
Next Every GLEnable after the Hook has been Initialized Code:
for (int ax=0;ax<Player.size();ax++)
{
int px = GetPlayerByIndexX(ax);
if(CalcScreen(Player[px].ent->origin,vecScreen))
{
if(Player[px].team==1){ DrawHudString(vecScreen[0],vecScreen[1]-16,Player[px].entinfo.name,255,40,40,true); }
if(Player[px].team==2){ DrawHudString(vecScreen[0],vecScreen[1]-16,Player[px].entinfo.name,40,80,255,true); }
}
}
Credits:unknown