daily pastebin goal
73%
SHARE
TWEET

Untitled

a guest Jan 21st, 2018 41 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int GetBestTarget(HANDLE hProcess, DWORD dwClient, float fMyX, float fMyY, float fMyZ, DWORD dwEngine)
  2. {
  3. int iPlayerID = 0;
  4. int iPlayerTeam = NULL;
  5. int iPlayerHealth = NULL;
  6. int iMyTeam = NULL;
  7. int iBestTarget = NULL;
  8.  
  9. float fShortestDistance = 0.0f;
  10. bool bPlayerIDIsTarget[64] = {};
  11. float fPlayerIsDistance[64] = {};
  12.     while( iPlayerID < 64 )
  13.     {
  14.     iMyTeam = LocalPlayer.Integers.Team;
  15.     iPlayerTeam = Players[iPlayerID].Integers.Team;
  16.     iPlayerHealth = Players[iPlayerID].Integers.Health;
  17.  
  18.         if( ( iMyTeam != iPlayerTeam ) && ( iPlayerHealth > 0 ) )
  19.         {
  20.         bPlayerIDIsTarget[iPlayerID] = true;
  21.         fPlayerIsDistance[iPlayerID] = gMath.GetDistance(LocalPlayer.Vectors.AbsOrigin, Players[iPlayerID].Vectors.AbsOrigin);
  22.             if(fShortestDistance == 0.0f)
  23.             {
  24.             fShortestDistance = fPlayerIsDistance[iPlayerID];
  25.             iBestTarget = iPlayerID;
  26.            
  27.             }
  28.             else if( fShortestDistance > fPlayerIsDistance[iPlayerID] )
  29.             {
  30.             fShortestDistance = fPlayerIsDistance[iPlayerID];
  31.             iBestTarget = iPlayerID;
  32.             }
  33.  
  34.         }
  35.     iPlayerID++;
  36.     }
  37. //std::cout << cGetName(dwClient, hProcess, iBestTarget) << std::endl;
  38. return iBestTarget;
  39. }
RAW Paste Data
Top