Advertisement
Guest User

QTS no. 20 - Statistics ( Frames per second, Client size, Date & Time )

a guest
Aug 15th, 2010
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 20 - Statistics ( Frames per second, Client size, Date & Time )
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21.  
  22. #include <time.h>
  23.  
  24.  
  25. //----------------------------------//
  26.     //Client stats
  27.  
  28.     D3DVIEWPORT9 pViewPort;
  29.  
  30.     pDevice->GetViewport( &pViewPort );
  31.  
  32.     CDraw.String( 10, 10, CDraw.m_coRed, FF_DEFAULT, "Screen Width: %d Height: %d", pViewPort.Width, pViewPort.Height );
  33.    
  34.  
  35.     //----------------------------------//
  36.     // Date and time
  37.  
  38.     time_t rawtime;
  39.     struct tm * timeinfo;
  40.  
  41.     time ( &rawtime );
  42.     timeinfo = localtime( &rawtime );
  43.  
  44.     CDraw.String( 10, 30, CDraw.m_coRed, FF_DEFAULT, asctime (timeinfo) );
  45.  
  46.  
  47.     //----------------------------------//
  48.     // Frames per second
  49.  
  50.     static float fLastTime = GetTickCount(),
  51.                  fCurrentTime = GetTickCount();
  52.  
  53.     static float fFramesPerSecond = 0,
  54.                  fTotal = 0,
  55.                  fAverage = 0;
  56.  
  57.  
  58.     fCurrentTime = GetTickCount();
  59.  
  60.     fTotal = ( fFramesPerSecond + 0.1f ) / ( ( fCurrentTime - fLastTime )/1000 );
  61.  
  62.     if( fCurrentTime - fLastTime > 5000 )
  63.     {
  64.         fLastTime = fCurrentTime;
  65.         fFramesPerSecond = 0;
  66.         fAverage = fTotal;
  67.     }
  68.  
  69.     CDraw.String( 10, 40, CDraw.m_coRed, FF_DEFAULT, "FPS: %f", ( fTotal == 0 ? fAverage : fTotal ) );
  70.  
  71.  
  72.     fFramesPerSecond++;
  73.    
  74.  
  75. //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement