- #include codjumper\_cj_utility;
- init()
- {
- precachestring(&":");
- precachestring(&" ");
- level.clientid = 0;
- level thread onPlayerConnect();
- }
- onPlayerConnect()
- {
- while( true )
- {
- level waittill("connecting", player);
- player.clientid = level.clientid;
- level.clientid++;
- player.stopwatchrunning = false;
- player thread onPlayerSpawned();
- }
- }
- onPlayerSpawned()
- {
- self endon("disconnect");
- while( true )
- {
- self waittill( "menuresponse", menu, response );
- if( menu == "cj" )
- {
- if( response == "stopwatchstart" )
- self thread start();
- if( response == "stopwatchstop" )
- self thread stop();
- }
- wait 0.5;
- }
- }
- start()
- {
- if(!self.stopwatchrunning)
- {
- self thread make_secondswatch();
- self thread make_minuteswatch();
- self thread dots_inbetween();
- self.stopwatchrunning = true;
- }
- else
- self iprintlnbold("The stopwatch is already running!");
- }
- make_secondswatch()
- {
- self endon( "stopwatch_destroy" );
- self.secondwatch = newclienthudelem(self);
- self.secondwatch.x = 322; //max 650
- self.secondwatch.y = 450; //max 475
- self.secondwatch.alignX = "left";
- self.secondwatch.alignY = "bottom";
- self.secondwatch.font = "default";
- self.secondwatch.fontScale = 2;
- self.secondwatch.archived = false;
- self.secondwatch.color = (1, 1, 1);
- for(;;)
- {
- secondtime = 0;
- secondtime = secondtime * 10;
- seconds = 0;
- for(i=seconds;i<=59;i++)
- {
- self.secondtime = i ;
- self.secondwatch setValue(self.secondtime);
- wait 1;
- }
- wait 0.05;
- }
- }
- make_minuteswatch()
- {
- self endon( "stopwatch_destroy" );
- self.minutewatch = newclienthudelem(self);
- self.minutewatch.x = 311; //max 650
- self.minutewatch.y = 450; //max 475
- self.minutewatch.alignX = "right";
- self.minutewatch.alignY = "bottom";
- self.minutewatch.font = "default";
- self.minutewatch.fontScale = 2;
- self.minutewatch.archived = false;
- self.minutewatch.color = (1, 1, 1);
- self.minutetime = 0;
- minutes = 0; //And no I don't know why I used this instead of just putting i=0;
- for(i=minutes;i>=0;i++)
- {
- self.minutewatch setValue(self.minutetime);
- if(self.secondtime == 599/10) self.minutetime++;
- wait 0.1;
- }
- }
- dots_inbetween()
- {
- self endon( "stopwatch_destroy" );
- self.dots = newclienthudelem(self);
- self.dots.x = 318; //max 650
- self.dots.y = 450; //max 475
- self.dots.alignX = "right";
- self.dots.alignY = "bottom";
- self.dots.font = "default";
- self.dots.fontScale = 2;
- self.dots.archived = false;
- self.dots.color = (1, 1, 1);
- for(;;)
- {
- self.dots.label = &":";
- wait 0.7;
- self.dots.label = &" ";
- wait 0.7;
- }
- }
- stop()
- {
- if(self.stopwatchrunning)
- {
- self notify( "stopwatch_destroy" );
- self iprintlnbold( self.minutetime + " minutes " + self.secondtime + " seconds" );
- self.secondtime = 0;
- self.minutetime = 0;
- self.minutewatch destroy();
- self.secondwatch destroy();
- self.dots destroy();
- self.stopwatchrunning = false;
- }
- else
- self iprintlnbold("You didn't start the stopwatch!");
- }