Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int GetBestTarget(HANDLE hProcess, DWORD dwClient, float fMyX, float fMyY, float fMyZ, DWORD dwEngine)
- {
- int iPlayerID = 0;
- int iPlayerTeam = NULL;
- int iPlayerHealth = NULL;
- int iMyTeam = NULL;
- int iBestTarget = NULL;
- float fShortestDistance = 0.0f;
- bool bPlayerIDIsTarget[64] = {};
- float fPlayerIsDistance[64] = {};
- while( iPlayerID < 64 )
- {
- iMyTeam = LocalPlayer.Integers.Team;
- iPlayerTeam = Players[iPlayerID].Integers.Team;
- iPlayerHealth = Players[iPlayerID].Integers.Health;
- if( ( iMyTeam != iPlayerTeam ) && ( iPlayerHealth > 0 ) )
- {
- bPlayerIDIsTarget[iPlayerID] = true;
- fPlayerIsDistance[iPlayerID] = gMath.GetDistance(LocalPlayer.Vectors.AbsOrigin, Players[iPlayerID].Vectors.AbsOrigin);
- if(fShortestDistance == 0.0f)
- {
- fShortestDistance = fPlayerIsDistance[iPlayerID];
- iBestTarget = iPlayerID;
- }
- else if( fShortestDistance > fPlayerIsDistance[iPlayerID] )
- {
- fShortestDistance = fPlayerIsDistance[iPlayerID];
- iBestTarget = iPlayerID;
- }
- }
- iPlayerID++;
- }
- //std::cout << cGetName(dwClient, hProcess, iBestTarget) << std::endl;
- return iBestTarget;
- }
Add Comment
Please, Sign In to add comment