Pushok

radar

May 21st, 2012
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.68 KB | None | 0 0
  1. #include "CRadar.h"
  2.  
  3. using namespace MemUtils;
  4.  
  5. namespace Hack
  6. {
  7.     CRadar::CRadar( CSigInfo sigInfo )
  8.     {
  9.         try
  10.         {
  11.             CSigScanner sigScanner( sigInfo );
  12.            
  13.             m_ProcTools = CProcTools( );
  14.  
  15.             if( sigScanner.FindNext( ) )
  16.             {
  17.                 this->m_pRadarBaseOffset = sigScanner.GetFullAddress< DWORD >( );
  18.             }
  19.             else
  20.             {
  21.                 throw std::exception( "Could not find radar base offset!" );
  22.             }
  23.         }
  24.         catch( std::exception &e )
  25.         {
  26.             this->m_pRadarBaseOffset = nullptr;
  27.  
  28.             Warning( e.what( ) );
  29.        
  30.             return;
  31.         }
  32.     }
  33.  
  34.     BYTE* CRadar::BuildAddressByID( int playerID, int propOffset )
  35.     {
  36.         return (BYTE*)( (DWORD)this->m_pRadarBaseOffset + propOffset + 0x140 * playerID );
  37.     }
  38.  
  39.     int CRadar::GetPlayerHealth( int id )
  40.     {
  41.         IClientEntity* pClientEntity = GlobIfaces::g_pClientEntityList->GetClientEntity( id );
  42.         BYTE* pbAddress = nullptr;
  43.  
  44.         if( pClientEntity->IsDormant( ) )
  45.         {
  46.             C_BaseEntity* pBaseEntity = pClientEntity->GetBaseEntity( );
  47.  
  48.             DWORD dwOffset = CClientOffsets::GetOffset( "CBaseEntity", "m_iHealth" );
  49.  
  50.             pbAddress = (BYTE*)( (DWORD)pBaseEntity + dwOffset );
  51.  
  52.             return m_ProcTools.ReadInt( pbAddress );
  53.         }
  54.         else
  55.         {
  56.             pbAddress = this->BuildAddressByID( id, HEALTH_OFFSET );
  57.  
  58.             return m_ProcTools.ReadInt( pbAddress );
  59.         }
  60.     }
  61.  
  62.     Vector CRadar::GetPlayerOrigin( int id )
  63.     {
  64.         IClientEntity* pClientEntity = GlobIfaces::g_pClientEntityList->GetClientEntity( id );
  65.         BYTE* pbAddress = nullptr;
  66.  
  67.         if( pClientEntity->IsDormant( ) )
  68.         {
  69.             C_BaseEntity* pBaseEntity = pClientEntity->GetBaseEntity( );
  70.  
  71.             DWORD dwOffset = CClientOffsets::GetOffset( "CBaseEntity", "m_vecOrigin" );
  72.  
  73.             pbAddress = (BYTE*)( (DWORD)pBaseEntity + dwOffset );
  74.  
  75.             return m_ProcTools.ReadData< Vector >( pbAddress );
  76.         }
  77.         else
  78.         {
  79.             pbAddress = this->BuildAddressByID( id, ORIGIN_OFFSET );
  80.  
  81.             return m_ProcTools.ReadData< Vector >( pbAddress );
  82.         }
  83.     }
  84.  
  85.     QAngle CRadar::GetPlayerAngles( int id )
  86.     {
  87.         IClientEntity* pClientEntity = GlobIfaces::g_pClientEntityList->GetClientEntity( id );
  88.         BYTE* pbAddress = nullptr;
  89.  
  90.         if( pClientEntity->IsDormant( ) )
  91.         {
  92.             C_BaseEntity* pBaseEntity = pClientEntity->GetBaseEntity( );
  93.  
  94.             DWORD dwOffset = CClientOffsets::GetOffset( "CBaseEntity", "m_angRotation" );
  95.  
  96.             pbAddress = (BYTE*)( (DWORD)pBaseEntity + dwOffset );
  97.  
  98.             return m_ProcTools.ReadData< QAngle >( pbAddress );
  99.         }
  100.         else
  101.         {
  102.             pbAddress = this->BuildAddressByID( id, ANGLES_OFFSET );
  103.  
  104.             return m_ProcTools.ReadData< QAngle >( pbAddress );
  105.         }
  106.     }
  107.  
  108.     string CRadar::GetPlayerName( int id )
  109.     {
  110.         BYTE* pbAddress = nullptr;
  111.  
  112.         pbAddress = this->BuildAddressByID( id, NAME_OFFSET );
  113.  
  114.         return m_ProcTools.ReadString( pbAddress, 32 );
  115.     }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment