Advertisement
Guest User

Untitled

a guest
Sep 30th, 2010
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.94 KB | None | 0 0
  1. /* ******************************************************
  2.     CREDITS:
  3.         Originally made by LarzI
  4.         Re-written by g_aSlice
  5.         Improved by Alex 'Y_Less' Cole
  6.  
  7.  ****************************************************** */
  8.  
  9.  
  10. #include <a_samp>
  11.  
  12. public OnFilterScriptInit()
  13. {
  14.     SetTimer( "OneSecTimer", 1, true );
  15.    
  16.     return 1;
  17. }
  18.  
  19. forward OneSecTimer( );
  20. public  OneSecTimer( )
  21. {
  22.     static
  23.         s_NextSecond = 0,
  24.         s_PreviousTick = 0,
  25.         s_Seconds = -1 // Updated to reflect removed code.
  26.     ;
  27.     new
  28.         tick = GetTickCount( )
  29.     ;
  30.    
  31.     // This is just wasted calculations!  tick will be larger right from the start.
  32.     /*if ( s_NextSecond == 0 )
  33.     {
  34.         s_NextSecond = tick + 1000;
  35.         s_PreviousTick = tick;
  36.     }*/
  37.  
  38.     if ( tick >= s_NextSecond )
  39.     {
  40.         ++s_Seconds;
  41.        
  42.         printf( "%d - Ticks: %d", s_Seconds, tick - s_PreviousTick );
  43.        
  44.         s_PreviousTick = tick;
  45.        
  46.         s_NextSecond = tick + 1000; // This is better than adding 999 to it each function call.
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement