Solved csgo getting closest player to me

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

ImTrying

Newbie
Full Member
Jun 6, 2017
17
72
0
i cant find out why it dont give me the closest player to me

C++:
for (int i = 0; i < PlayerCount; i++)
		{
			Playerlist[i].enemyBase(i);
			
			AimTo = calcAngle(myPos2, bonePos);
			

			float distance[3];
			float NewDist = 0;
			float CurDist = 10000000;

			distance[0] = myPos2.x - Playerlist[i].enemyPos.x;
			distance[1] = myPos2.y - Playerlist[i].enemyPos.y;
			distance[2] = myPos2.z - Playerlist[i].enemyPos.z;


			NewDist = sqrt((distance[0] * distance[0]) + (distance[1] * distance[1]) + (distance[2] * distance[2]));


			if (NewDist < CurDist)
			{
				CurDist = NewDist;
			}
			if (Playerlist[i].eHealth < 2)
				continue;
			if (Playerlist[i].eTeam == PlayerBase.mTeam)
				continue;
			if (Playerlist[i].eTeam == PlayerBase.mTeam)			
			    continue;			
			if (Playerlist[i].eDormant == false)
			if (GetAsyncKeyState(0x1))
				{
				 WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(clientstate + viewAngle), &AimTo.y, sizeof(AimTo.y), 0);
				 WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(clientstate + viewAngle + 0x4), &AimTo.x, sizeof(AimTo.x), 0);
				}
		
		}

	}
}
 

HexMurder

Arcane Hacker
Dank Tier VIP
Dank Tier Donator
Jun 7, 2012
319
7,988
22
your code is very very messy so it's hard for me to fix but here is a quick attempt:

C++:
float distance[3];
float NewDist = 0;
float CurDist = 10000000;
int closestPlayer = 0;

for (int i = 0; i < PlayerCount; i++)
		{
			Playerlist[i].enemyBase(i);
			

  
			distance[0] = myPos2.x - Playerlist[i].enemyPos.x;
			distance[1] = myPos2.y - Playerlist[i].enemyPos.y;
			distance[2] = myPos2.z - Playerlist[i].enemyPos.z;


			NewDist = sqrt((distance[0] * distance[0]) + (distance[1] * distance[1]) + (distance[2] * distance[2]));


			if (NewDist < CurDist)
			{
				CurDist = NewDist;
        closestPlayer = i;
			}
			if (Playerlist[i].eHealth < 2)
				continue;
			if (Playerlist[i].eTeam == PlayerBase.mTeam)
				continue;
			if (Playerlist[i].eTeam == PlayerBase.mTeam)			
			    continue;			
			if (Playerlist[i].eDormant == false)

		
		}
			if (GetAsyncKeyState(0x1))
				{
                AimTo = calcAngle(myPos2, playerList[closestPlayer].bonePos);
				 WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(clientstate + viewAngle), &AimTo.y, sizeof(AimTo.y), 0);
				 WriteProcessMemory(fProcess.__HandleProcess, (PBYTE*)(clientstate + viewAngle + 0x4), &AimTo.x, sizeof(AimTo.x), 0);
				}
	}
heres how i would do it:
C++:
int Aimbot::GetClosest(LocalPlayer & localPlayer, Entity* entity)
{
	int tempClosest = -1;
	float tempDist = 999999;
	for (int i = 0;i < MAX_PLAYERS;i++)
	{
		if (entity[i].team != localPlayer.team && entity[i].health > 0 && !entity[i].bDormant)
		{
			float playerDist = Vec3::Dist(localPlayer.pos, entity[i].pos);

			if (playerDist < tempDist)
			{
				tempClosest = i;
				tempDist = playerDist;
			}
		}
	}
	return tempClosest;
}
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
you store CurDist in the for loop, so every iteration it gets re-written. put it outside of the loop.
 

ImTrying

Newbie
Full Member
Jun 6, 2017
17
72
0
you store CurDist in the for loop, so every iteration it gets re-written. put it outside of the loop.
that dont work if you you need i can give you more code to see if you see a problem

untill then im just going to keep trying to fix it
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods