I'm making an aimbot by moving the mouse, aiming to the nearest enemy to the player, if that enemy is visible on the screen.
DWORD WINAPI processThread(LPVOID)
bool isVisible = false;
float dist = FLT_MAX;
int nearIndex = -1;
for (int a = 0; a < gInfo.totalPlayers; a++)
//usual checking if player is enemy and alive
if (gInfo.totalPlayers != myPlayerIndex && playerBuf0[a].team != myPlayerBuf0.team && playerBuf0[a].hp > 0)
playerBuf0[a].screenCoordinates = //my world to screen function
//isVisible is also a parameter in w2s, where it states if the player is
//on the screen
//if the player is visible (on screen) then check if his distance
//is smaller than than the previous checked player
//The index is saved in "nearIndex"
if (playerBuf0[a].distance < dist)
nearIndex = a;
dist = playerBuf0[a].distance;
if (nearIndex != -1 && GetAsyncKeyState(CSGO_AIMKEY))
This is a seperate thread to the thread getting the information. The other thread is also the thread, where the distance for each player to my player is calculated.
The problem now is, that it won't aim to the closest enemy, but to the on first in the list.
Thanks for any help
Original Writen by tomatocake in General Programming and Reversing Category, the date of 26-06-2015 16:39.