most can do it, now to teach me..
ive got my timer inplace (idleAway)
and this is as much as ive done
Private Sub IdleAway_Timer()
idleAway.Interval = 30000
Dim Mins As Integer
Mins = Mins + 1
CleanSlateBot1.Send "/away Has been idle for " & Mins & " Seconds."
End Sub
am i missing anything? can someone help me plz
Did you set the initial interval?
Did you set it to enabled?
You aren't initializing Mins
You aren't remembering Mins
You're adding one to Mins every 30 seconds
You called Seconds Mins
Trying to remember as much VB as I can...
Once you're connected, you start by initializing your Timer (assuming that it's called IdleTimer elsewhere):
' This code MUST go somewhere else in your code that makes it global
' for example, a module
Dim Mins As Integer
Dim Away As Boolean
' Start your timer upon connection to BNCS
Private Sub CleanSlateBot1_Connect ()
' .... other init stuff here
IdleTimer.Interval = 60000
Mins = 0
Away = False
IdleTimer.Start
End Sub
Private Sub IdleTimer_Tick()
Mins = Mins + 1
If Away Then
CleanSlateBot1.Send "/away"
Away = False
End If
CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
Away = True
End Sub
Now, if you wanted to do something so that you would reset the timer whenever typing happened:
Private Sub TextBox1_TextChanged()
Mins = 0
If (Away) Then
CleanSlateBot1.Send("/away")
Away = False
End If
IdleTimer.Stop
IdleTimer.Start
End Sub
Now, I'm not sure if my code works or not, because I'm not a VB6 programmer. What I want you to understand is why I did what I did.
Your Mins variable is going to be available throughout your code. It needs to be accessible at a global level. That's why we declared it in a module.
You want your timer to update your away message each minute. Thus, you set your interval to 60 seconds (or 60,000 milliseconds) so that its event handler is called every 60 seconds. You also want to initialize your minutes count to zero, so that the first time your away message is set, it sets to 1 minute.
Each time your timer ticks, it increments your minutes count, and sends two messages over CSB: the first is a standard "/away" to clear your previous away message, and the second sets your new away status. If you weren't previously marked away (this is where the Boolean value Away comes in), then it doesn't send the first one. That way your away states are kept straight (assuming B.net responds as it should).
I'm not sure how CSB works, but I assumed that you need to have a textbox in the form to enter your chat text. I just called it "TextBox1" and wired up to the TextChanged event. Since you're no longer idle when you are typing something at the console, it clears your away status and restarts your timers. The .Stop then .Start commands effectively reset your timer's count to zero.
Hope this helps - and works!
--Rob
You're sending your idle message every 30 seconds?
Ugh, you really ought to let him figure stuff out for himself; he won't learn anything if you copy/paste!!
Quote from: Myndfyre on October 30, 2003, 05:40 PM
Private Sub IdleTimer_Tick()
Mins = Mins + 1
If Away Then
CleanSlateBot1.Send "/away"
Away = False
End If
CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
Away = True
End Sub
Each time your timer ticks, it increments your minutes count, and sends two messages over CSB: the first is a standard "/away" to clear your previous away message, and the second sets your new away status. If you weren't previously marked away (this is where the Boolean value Away comes in), then it doesn't send the first one. That way your away states are kept straight (assuming B.net responds as it should).
It's actually not necessary to send the first /away. Attempting to set one away message while you already have another in place immediately overwrites the old one. You don't need to explicitly clear it first.
thx mate
and iago, i do like to learn its just it kept me up til 3am working on it and i needed help.
oh and i only named it "Mins" cuz its old names was "Fuckers"
EDIT: wont compile, "IdleTimer.Start"
Figure it out! That's the only way to learn. :P
as much as i hate spamming, the timer wont change from 1min
Private Sub CleanSlateBot1_Connect()
IdleTimer.Interval = 60000
Mins = 0
Away = False
IdleTimer.Start
End Sub
Private Sub IdleTimer_Tick()
Mins = Mins + 1
If Away Then
CleanSlateBot1.Send "/away"
Away = False
End If
CleanSlateBot1.Send "/away Has been idle for " & Mins & " minutes."
Away = True
End Sub
Private Sub Info_TextChanged()
Mins = 0
If (Away) Then
CleanSlateBot1.Send ("/away")
Away = False
End If
IdleTimer.Stop
IdleTimer.Start
End Sub
anyone know why ?
Because, you're incrimenting Mins but not doing anything with it. I suggest setting the idle interval to 1 second, and checking the value of Mins before sending the idle message. Something like...
if mins >= 120 then
send "/message"
mins = 0
end if
+1 to warz because ... well because he only had +8.
Hm, whats wrong with just:
Dim varIdle As String
Private Sub IdleMsg_Timer()
varIdle = GetStuff("Config", "Main", "IdleMessage")
Send varIdle '<-- This is how mines setup, I'm not using CSB
End Sub
And on connect have it...
IdleMsg.Enabled = True
IdleMsg.Interval = varIdleTick * 100 '(Sets it up for seconds instead of the normal milliseconds)
And last but not least, on disconnect:
IdleMsg.Enabled = False
That works for me and it's incredibly simple.
cuz thats not what i was after.. Anyway the problem has been resolved, if anyone would like to know how feel free to pm me or aim me or trick (ps. thx for the help trick)
Quote from: Crim-Training on November 03, 2003, 03:05 AM
cuz thats not what i was after.. Anyway the problem has been resolved, if anyone would like to know how feel free to pm me or aim me or trick (ps. thx for the help trick)
Why wouldn't you just post it here?
Quote from: iago on November 03, 2003, 03:13 AM
Why wouldn't you just post it here?
i dont want you to laugh and make a fool out of myself
well.. if u must ill upload
http://zonebot.ath.cx/users/crim/awayidle.zip
Quote from: Crim-Training on November 03, 2003, 06:09 AM
Quote from: iago on November 03, 2003, 03:13 AM
Why wouldn't you just post it here?
i dont want you to laugh and make a fool out of myself
well.. if u must ill upload
http://zonebot.ath.cx/users/crim/awayidle.zip
Why would they laugh? As long as your code works I see no reason to laugh. (Except for the fact that you spelled 'milliseconds' wrong :P)
Quote from: Crim-Training on November 03, 2003, 06:09 AM
Quote from: iago on November 03, 2003, 03:13 AM
Why wouldn't you just post it here?
i dont want you to laugh and make a fool out of myself
well.. if u must ill upload
http://zonebot.ath.cx/users/crim/awayidle.zip
sorry to bring this back up, but did anyone download that file ? i lost it when i had to format
Quote from: Dyndrilliac on November 02, 2003, 02:05 PM
IdleMsg.Enabled = True
IdleMsg.Interval = varIdleTick * 100 '(Sets it up for seconds instead of the normal milliseconds)
Seconds = Milliseconds * 1000 (not 100) :)