Guest User

Untitled

a guest
Sep 30th, 2010
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.63 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. public OnFilterScriptInit()
  4. {
  5.     SetTimer( "OneSecTimer", 1, true );
  6.    
  7.     return 1;
  8. }
  9.  
  10. forward OneSecTimer( );
  11. public  OneSecTimer( )
  12. {
  13.     static
  14.         s_NextSecond = 0,
  15.         s_PreviousTick = 0,
  16.         s_Seconds = 0
  17.     ;
  18.    
  19.     if ( s_NextSecond == 0 )
  20.     {
  21.         s_NextSecond = GetTickCount( ) + 1000;
  22.         s_PreviousTick = GetTickCount( );
  23.     }
  24.  
  25.     if ( GetTickCount( ) >= s_NextSecond )
  26.     {
  27.         s_Seconds++;
  28.        
  29.         printf( "%d - Ticks: %d", s_Seconds, GetTickCount( ) - s_PreviousTick );
  30.        
  31.         s_PreviousTick = GetTickCount( );
  32.        
  33.         s_NextSecond = GetTickCount( ) + 1000; // This is better than adding 999 to it each function call.
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment