Using a Weapon Scope

     The script below counts down from 1 hour. Although the variables are labeled seconds and milliseconds, the actual time rate is controlled with the line: milliseconds = milliseconds - 1 * self.averageTick;. The value, 1 * self.averageTick, refers to 1 second. The script also checks whether or not the length of the count is more then 1 digit and if not, adds a 0 in front of the value. If the clock has not reached 0 then the function returns false. If it has reached 0, then a true value is returned.

{

seconds[59]
milliseconds[59]


    Init[()
    {
        DrawClock();
    }]

    DrawClock[()
    {
        sec = toInt(seconds);
        millisec = toInt(milliseconds);
        if (length(sec)<2)
        {
            sec = "0" # sec;
        }
        if (length(millisec)<2)
        {
            millisec = "0" # millisec;
        }
        tt = sec # ":" # millisec;
        DrawText(font,tt,135,20,255,0,0,128);
        milliseconds = milliseconds - 1 * self.averageTick;
        if(milliseconds < 0)
        {
            milliseconds = 60;
            seconds = seconds - 1;
            if(seconds < 0)
            {
                return true;
            }
        }

        return false;
        }]

}

Copyright © 2008 Bookshock Publications.