This tutorial is for ESP and includes Model Detection
http://www.ccoders.cproj.com
For this tutorial, you will need:
MSVC++ 6.0
An OpenGL Wrapper
General C++ Knowledge
First of all, your going to have to be able to detect the Vertex Distances if you want to use ESP. Vertex distances are what is used to determine which model is which.
Basically, heres what your going to have to do for ESP:
Globals:
Set up a text document to store the vertdistances
Seperate Function:
Set up a distance calculating function
glPushMatrix:
Set vertcount to 0
glVertex3f:
Calc Distances, Run actual highlighting code
So, how are we going to do all this? Well, I have some basic code for the calculating, printing, etc. (Sorry original author, I don't know who you are :( )
//================================================== =
// Global Vars
FILE *outfile=fopen("output.txt", "w");
GLfloat vTexDist;
int vertexCount=0;
GLfloat vTexOneX,vTexOneY,vTexOneZ,vTexTwoX,vTexTwoY,vTexT woZ;
//================================================== =
// Print Function
void PrintDist()
{
outfile<<vTexDist<<endl;
}
// Distance Calculation Function
GLfloat GetDist(GLfloat firstX,GLfloat firstY,GLfloat firstZ,GLfloat secX,GLfloat secY,GLfloat secZ)
{
return (GLfloat)sqrt((((secX-firstX)*(secX-firstX))+((secY-firstY)*(secY-firstY))+((secZ-firstZ)*(secZ-firstZ))));
}
//================================================== =
// In glPushMatrix
vertexCount=0;
//================================================== =
// In glVertex3f
if(vertexCount==8)
{
// Note x,y, and z are the values passed to glVertex3f
vTexOneX=x;
vTexOneY=y;
vTexOneZ=z;
}
if(vertexCount==9)
{
// Note x,y, and z are the values passed to glVertex3f
vTexTwoX=x;
vTexTwoY=y;
vTexTwoZ=z;
}
if(vertexCount==10)
{
// Calculate Distance And Print To File
vTexDist=GetDist(vTexOneX,vTexOneY,vTexOneZ,vTexTw oX,vTexTwoY,vTexTwoZ);
PrintDist();
}
vertexCount++;
//================================================== =
So, this is pretty scary eh? I'll explain it to you.
Globals: These are fairly obvious, what you need to run the program.
PrintDist: Simply prints to a file
GetDist: Uses the formula sqrt((((secX-firstX)*(secX-firstX))+((secY-firstY)*(secY-firstY))+((secZ-firstZ)*(secZ-firstZ)))) to display the distance.
PushMatrix: This will be called every time the game is done drawing something, such as a player model or gun. This lets you reset the vertexcount to 0.
Vertex3f: This is called a lot in drawing, so heres when you can do your actual checks. This is what draws the models and guns, so thats how you can draw something such as red coloring overtop.
Now is time for some logging. Since you have gotten this far, your gonna have to do the logging on your own. Gotta let you learn something now don't I?
To do the logging, simply place OpenGL32.dll into you Counter-Strike or w/e folder, then spectate a bot for a few seconds. If you can, make him switch weapons and stuff, to ensure accurate logging.
After your done that, open up outfile.txt. You should see something like:
1.232
5.323
5.432
1.233
4.332
1.231
4.222
(The actual file will be MUCH longer)
What these numbers mean, are the VertDistances of each model. Choose the most recurring, in this case 1.232, and you will most likely have your player model.
Now, heres the fun part: The actual ESP. This is actually incredibly easy when you have the logging done; Simply write the following code:
//NEW GLOBAL!
bool highlight=false;
//NEW GLVERTEX3f
if(vertexCount==8)
{
// Note x,y, and z are the values passed to glVertex3f
vTexOneX=x;
vTexOneY=y;
vTexOneZ=z;
}
if(vertexCount==9)
{
// Note x,y, and z are the values passed to glVertex3f
vTexTwoX=x;
vTexTwoY=y;
vTexTwoZ=z;
}
if(vertexCount==10)
{
// Calculate Distance And Print To File
vTexDist=GetDist(vTexOneX,vTexOneY,vTexOneZ,vTexTw oX,vTexTwoY,vTexTwoZ);
if((vTexDist>2.23f)&&(vTexDist<1.24f))
{
highlight=true;
}
}
if(highlight)
{
glColor3f(1.0f,0.0f,0.0f);
}
vertexCount++;
}
[/php]
Do this for all 8 models and you have ESP for your hack!
GL and Have Fun Coding!
A few Verts I've found for CS 1.6 are as folllowed:
[php]
//CT'S
if((vTexDist>3.640f)&&(vTexDist<3.641f))
{
highlight=true;
}
else if((vTexDist>10.781f)&&(vTexDist<10.782f))
{
highlight=true;
}
else if((vTexDist>2.869f)&&(vTexDist<2.870f))
{
highlight=true;
}
else if((vTexDist>0.340f)&&(vTexDist<0.341f))
{
highlight=true;
}
else
{
highlight=false;
}
//T'S
if((vTexDist>2.0974f)&&(vTexDist<2.0976f))
{
thighlight=true;
}
else if((vTexDist>2.232f)&&(vTexDist<2.235f))
{
thighlight=true;
}
else if((vTexDist>2.328f)&&(vTexDist<2.329f))
{
thighlight=true;
}
else if((vTexDist>3.697f)&&(vTexDist<3.698f))
{
thighlight=true;
}
else
{
thighlight=false;
}
(No this is not me copying and pasting a tutorial, I just didn't write the code, since its a lot easier just to use what you found rather then programming it yourself :cool: Apparantly the original author, whoever he is, had this code in a tutorial.)