Advertisement
soulshaker

VC:MP Uptime

Sep 20th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 1.14 KB | None | 0 0
  1. function onScriptLoad()
  2. {
  3. TicksStart <- 0;
  4. TicksStart = GetTickCount();
  5. }
  6.  
  7. function Timing( ticks )
  8. {
  9.     ticks   = floor ( ticks / 1000 );
  10.     local days = floor ( ticks % 604800 / 86400 );
  11.     local hours = floor ( ticks % 86400 / 3600 );
  12.     local mins = floor ( ticks % 3600 / 60 );
  13.     local secs = ticks % 60;
  14.     local weeks = floor ( ( ticks - days*86400 - hours*3600 - mins*60 - secs ) / 604800 );
  15.     local a = [];
  16.     if ( weeks != 0 ) a.append( weeks + " weeks " );
  17.     if ( days != 0 ) a.append( days + " days " );
  18.     if ( hours != 0 ) a.append( hours + " hours " );
  19.     if ( mins != 0 ) a.append( mins + " minutes and " );
  20.     if ( secs != 0 ) a.append( secs + " seconds" );
  21.     return JoinArray( a, " " );
  22. }
  23.  
  24. function JoinArray( array, delimit )
  25. {
  26.     local a, z = array.len(), output = "";
  27.     if ( z > 0 )
  28.     {
  29.         if ( z > 1 )
  30.         {
  31.             for ( a = 1; a < z; a++ )
  32.                 output += delimit + array[ a ];
  33.             return array[ 0 ] + output;
  34.         }
  35.         else return array[ 0 ];
  36.     }
  37.     else return output;
  38. }
  39.  
  40. function onPlayerCommand( player, cmd, text )
  41. {
  42. if ( cmd == "uptime" )
  43. {
  44. MessagePlayer( "** Uptime " + Timing( floor( GetTickCount() - TicksStart ) ) + "." , player);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement