Jump to content
UBot Underground

[GET] UI Timer Source Code


Recommended Posts

Here's a source for a UI timer for everyone to use.

 

The first timer is for "Advanced Ubot" owners with "comparison x2". The second timer is without.

 

The timer is in 00:00:00 format.

 

Hope it helps..

ui stat monitor("Timer: ", #timer)
ui stat monitor("Status: ", #status)
ui drop down("Wait: ", "5,10,15,30,60,90,120,150,180,210,240,3600,7200", #wait)
set(#seconds, 54, "Global")
set(#minutes, 59, "Global")
set(#hours, 00, "Global")
set(#status, "Running", "Global")
thread {
    loop while($comparison(#status, "=", "Running")) {
        set(#timer, $Timer(), "Global")
        wait(1)
    }
}
wait(#wait)
set(#status, "Complete", "Global")
define $Timer {
    increment(#seconds)
    if($comparison(#seconds, "=", 60)) {
        then {
            set(#seconds, 0, "Global")
            increment(#minutes)
        }
    }
    if($comparison(#minutes, "=", 60)) {
        then {
            set(#minutes, 00, "Global")
            increment(#hours)
        }
    }
    if($comparison(#seconds, "<", 10)) {
        then {
            set(#seconds, "0{#seconds}", "Global")
        }
    }
    if($plugin function("Advanced Ubot.dll", "$comparison x2", #minutes, "<", 10, "&&", #minutes, ">", 0)) {
        then {
            set(#minutes, "0{#minutes}", "Global")
            set(#minutes, $replace(#minutes, 00, 0), "Global")
        }
    }
    if($plugin function("Advanced Ubot.dll", "$comparison x2", #hours, "<", 10, "&&", #hours, ">", 0)) {
        then {
            set(#hours, "0{#hours}", "Global")
            set(#hours, $replace(#hours, 00, 0), "Global")
        }
    }
    set(#timer, "{#hours}:{#minutes}:{#seconds}", "Global")
    return(#timer)
}
define $Timer2 {
    increment(#seconds)
    if($comparison(#seconds, "=", 60)) {
        then {
            set(#seconds, 0, "Global")
            increment(#minutes)
        }
    }
    if($comparison(#minutes, "=", 60)) {
        then {
            set(#minutes, 00, "Global")
            increment(#hours)
        }
    }
    if($comparison(#seconds, "<", 10)) {
        then {
            set(#seconds, "0{#seconds}", "Global")
        }
    }
    if($both($comparison(#minutes, ">", 0), $comparison(#minutes, ">", 0))) {
        then {
            set(#minutes, "0{#minutes}", "Global")
            set(#minutes, $replace(#minutes, 00, 0), "Global")
        }
    }
    if($both($comparison(#hours, ">", 0), $comparison(#hours, ">", 0))) {
        then {
            set(#hours, "0{#hours}", "Global")
            set(#hours, $replace(#hours, 00, 0), "Global")
        }
    }
    set(#timer, "{#hours}:{#minutes}:{#seconds}", "Global")
    return(#timer)
}
  • Like 1
Link to post
Share on other sites

Oh and the timer and wait amount in the example isn't synced properly for some reason, but the function works well. It works for 5 sec and 10 sec, but losing a sec for 15 sec, and 2 sec for 30 sec. So I guess it loses a second every 15 seconds or so..

Link to post
Share on other sites
  • 2 weeks later...

has there been any update to this?I wanted a timer that can be like a productivity tool to capture how long somebody has been using his computer to be used inside a bot.

Edited by cob007
Link to post
Share on other sites
  • 4 months later...

Hey Acamso, 

Great work, Very useful implementing this into my script. Had to fix the Timer2 function. It was adding an extra "0" once it goes past 10 for minutes and hours.

 

Before:

($both($comparison(#VAR, ">", 0), $comparison(#VAR, ">", 0)))

 

After:
($both($comparison(#VAR, ">", 0), $comparison(#VAR, "<", 10)))
 

define $Timer2 {
    increment(#seconds)
    if($comparison(#seconds, "=", 60)) {
        then {
            set(#seconds, 0, "Global")
            increment(#minutes)
        }
    }
    if($comparison(#minutes, "=", 60)) {
        then {
            set(#minutes, 00, "Global")
            increment(#hours)
        }
    }
    if($comparison(#seconds, "<", 10)) {
        then {
            set(#seconds, "0{#seconds}", "Global")
        }
    }
    if($both($comparison(#minutes, ">", 0), $comparison(#minutes, "<", 10))) {
        then {
            set(#minutes, "0{#minutes}", "Global")
            set(#minutes, $replace(#minutes, 00, 0), "Global")
        }
    }
    if($both($comparison(#hours, ">", 0), $comparison(#hours, "<", 10))) {
        then {
            set(#hours, "0{#hours}", "Global")
            set(#hours, $replace(#hours, 00, 0), "Global")
        }
    }
    set(#timer, "{#hours}:{#minutes}:{#seconds}", "Global")
    return(#timer)
}

I added a check to compare 2 different times to stop the script if someone looking for that method. More Info: (http://www.ubotstudio.com/forum/index.php?/topic/17427-ui-timer-stops-the-script/)

 

Regards, 
HaHaItsJake

Link to post
Share on other sites

Here is a much shorter and more accurate method (using my datetime manipulation plugin):

ui drop down("Wait","1,2,3,4,5,10,15,20",#TIME Wait)
ui stat monitor("Time",#TIME)
set(#TIME Start,$plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"),"Global")
set(#TIME End,$add(#TIME Start,#TIME Wait),"Global")
loop while($comparison($plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"),"<=",#TIME End)) {
    set(#TIME,$subtract($plugin function("DateTime Manipulation.dll", "$datetime manipulation", $date, "UBOT", "UNIX", "en-US", "en-US"),#TIME Start),"Global")
    wait(0.1)
}

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...