Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 4.74 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include codjumper\_cj_utility;
  2.  
  3.     init()
  4.     {
  5.             precachestring(&":");
  6.             precachestring(&" ");
  7.            
  8.             level.clientid = 0;
  9.             level thread onPlayerConnect();
  10.     }
  11.      
  12.     onPlayerConnect()
  13.     {
  14.             while( true )
  15.             {
  16.                     level waittill("connecting", player);
  17.                    
  18.                     player.clientid = level.clientid;
  19.                     level.clientid++;
  20.                    
  21.                     player.stopwatchrunning = false;
  22.                    
  23.                     player thread onPlayerSpawned();
  24.             }
  25.     }
  26.      
  27.     onPlayerSpawned()
  28.     {
  29.             self endon("disconnect");
  30.            
  31.             while( true )
  32.             {
  33.                     self waittill( "menuresponse", menu, response );
  34.                     if( menu == "cj" )
  35.                     {
  36.                             if( response == "stopwatchstart" )
  37.                                     self thread start();
  38.                             if( response == "stopwatchstop" )
  39.                                     self thread stop();
  40.                     }
  41.                     wait 0.5;
  42.             }
  43.     }
  44.      
  45.      
  46.      
  47.     start()
  48.     {
  49.             if(!self.stopwatchrunning)
  50.             {
  51.                     self thread make_secondswatch();
  52.                     self thread make_minuteswatch();
  53.                     self thread dots_inbetween();
  54.                     self.stopwatchrunning = true;
  55.             }
  56.             else
  57.                     self iprintlnbold("The stopwatch is already running!");
  58.     }
  59.      
  60.     make_secondswatch()
  61.     {
  62.             self endon( "stopwatch_destroy" );
  63.             self.secondwatch = newclienthudelem(self);
  64.             self.secondwatch.x = 322; //max 650
  65.             self.secondwatch.y = 450; //max 475
  66.             self.secondwatch.alignX = "left";
  67.             self.secondwatch.alignY = "bottom";
  68.             self.secondwatch.font = "default";
  69.             self.secondwatch.fontScale = 2;
  70.             self.secondwatch.archived = false;
  71.             self.secondwatch.color = (1, 1, 1);
  72.             for(;;)
  73.             {
  74.                     secondtime = 0;
  75.                     secondtime = secondtime * 10;
  76.                     seconds = 0;
  77.                     for(i=seconds;i<=59;i++)
  78.                     {
  79.                             self.secondtime = i ;
  80.                             self.secondwatch setValue(self.secondtime);
  81.                             wait 1;
  82.                     }
  83.                     wait 0.05;
  84.             }
  85.     }
  86.      
  87.     make_minuteswatch()
  88.     {
  89.             self endon( "stopwatch_destroy" );
  90.             self.minutewatch = newclienthudelem(self);
  91.             self.minutewatch.x = 311; //max 650
  92.             self.minutewatch.y = 450; //max 475
  93.             self.minutewatch.alignX = "right";
  94.             self.minutewatch.alignY = "bottom";
  95.             self.minutewatch.font = "default";
  96.             self.minutewatch.fontScale = 2;
  97.             self.minutewatch.archived = false;
  98.             self.minutewatch.color = (1, 1, 1);
  99.             self.minutetime = 0;
  100.             minutes = 0; //And no I don't know why I used this instead of just putting i=0;
  101.             for(i=minutes;i>=0;i++)
  102.             {
  103.                     self.minutewatch setValue(self.minutetime);
  104.                     if(self.secondtime == 599/10) self.minutetime++;
  105.                             wait 0.1;
  106.             }
  107.     }
  108.      
  109.     dots_inbetween()
  110.     {
  111.             self endon( "stopwatch_destroy" );
  112.             self.dots = newclienthudelem(self);
  113.             self.dots.x = 318; //max 650
  114.             self.dots.y = 450; //max 475
  115.             self.dots.alignX = "right";
  116.             self.dots.alignY = "bottom";
  117.             self.dots.font = "default";
  118.             self.dots.fontScale = 2;
  119.             self.dots.archived = false;
  120.             self.dots.color = (1, 1, 1);
  121.             for(;;)
  122.             {
  123.                     self.dots.label = &":";
  124.                     wait 0.7;
  125.                     self.dots.label = &" ";
  126.                     wait 0.7;
  127.             }
  128.     }
  129.      
  130.      
  131.     stop()
  132.     {
  133.             if(self.stopwatchrunning)
  134.             {
  135.                     self notify( "stopwatch_destroy" );
  136.                     self iprintlnbold( self.minutetime + " minutes " + self.secondtime + " seconds" );
  137.                     self.secondtime = 0;
  138.                     self.minutetime = 0;
  139.                     self.minutewatch destroy();
  140.                     self.secondwatch destroy();
  141.                     self.dots destroy();
  142.                     self.stopwatchrunning = false;
  143.             }
  144.             else
  145.                     self iprintlnbold("You didn't start the stopwatch!");
  146.     }