Author Topic: counter  (Read 7920 times)

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
counter
« on: May 03, 2006, 10:54:13 AM »
How do I make a simple counter that counts lines posted, or specific words oslt. It's only the counter thing I need help with.
I tried something like:
Code: [Select]
Dim Counter
Counter = 0
When something specific happens:
Counter = Counter + 1

But that didn't work
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #1 on: May 03, 2006, 10:56:05 AM »
You Dim the counter variable outside of any subs, so at the very beginning of the script is best.
Now, it will reset back to 0 each time the script is re-loaded as well.
The IceChat God

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #2 on: May 04, 2006, 06:37:07 AM »
Code: [Select]
Dim Counter
Counter = 0

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
  if Channel = "#KokkolanMetallipäät" then
    Counter = Counter + 1
    if Counter = 5 then
      Counter = 0
      SendCommand "/msg ^HellBreaker^ say #kokkolanmetallipäät kumartakaa Morioa"
    End if
  End if
End Sub

That is the script I wrote, but that seems to do pretty much nothing
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #3 on: May 04, 2006, 06:43:01 AM »
Also, how could I make a command that displays the counter status to me?
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #4 on: May 04, 2006, 07:56:14 AM »
Well, you do need to add ",ServerNumber" to the end of your SendCommand line, or it will send it on the current server.
Also, if that channel name is not perfect, it wont work either. Try it with a test channel and see how it works.

Make a script command and use /! command style to run that command, which would return the counter value.
The IceChat God

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #5 on: May 04, 2006, 09:36:54 AM »
still nothing :(
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #6 on: May 04, 2006, 11:16:47 AM »
Even with a test channel?
My guess is that its the wrong channel name, not a perfect match.
The IceChat God

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #7 on: May 05, 2006, 06:03:41 AM »
Still nothing, I tried it with a test channel, I even tried adding an LCase() around 'Channel' and changed to just small letters (and yes someone else typed the lines)
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #8 on: May 05, 2006, 10:00:45 AM »
Ok, I will whip up a test script myself and see what happens.
The IceChat God

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #9 on: May 06, 2006, 08:53:39 PM »
I pasted your script above, except for changing the channel, into a script, and it worked perfectly.
And this is what I used to disaply the counter.

Code: [Select]
'run this with /! ShowCounter
Sub ShowCounter()
SendCommand "/echo -a Counter=" & Counter
End Sub

This was done with the Beta of IceChat7.
The IceChat God

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #10 on: May 07, 2006, 12:46:56 AM »
hmm, no idea why it's not working for me then, I tried another channel, and made my bot paste 5 lines.

When I add the ShowCounter thingy, I get this, when trying to view the counter:

-- Script Engine Error:13:Type mismatch: 'ShowCounter': Line #1 --
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #11 on: May 07, 2006, 08:12:20 AM »
Is this saved as an ICE file or an ICS file?
Remember that in IceChat 7, you need to save VB Script (IceChat5) files as a different file type.
The IceChat God

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: counter
« Reply #12 on: May 07, 2006, 10:08:51 AM »
ok, didn't know that, now it seems to be working fine.

Also that's why the autorejoinpunisher didn't work when I tried it :D
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: counter
« Reply #13 on: May 07, 2006, 12:21:12 PM »
Ah, I thought somethig didnt seem right.

I have not made it be able to detect one script engine from the other yet, so thats why you save it was a different file type, so the Script Engine can check what the file extension is, and then will know if its the new or the old style of scripting.
The IceChat God