Author Topic: "Picker Bot"  (Read 4966 times)

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
"Picker Bot"
« on: March 21, 2008, 07:38:11 PM »
Is there a script that automatically chooses one nickname out of everyone in the channel and displays it. Like for example, these users were in a channel....

TheCellist42; Turtles; Ares; Rostropovich

I would type !pickuser (Or Something)

and the bot would say:

<Rostropovich> : !!  Turtles  !!

Any Ideas on where I could find something like that?
~ Sam
~ Visit my website at http://www.TheCellist42.com

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: "Picker Bot"
« Reply #1 on: March 22, 2008, 02:05:49 AM »
You could try something like this:

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

'check for the trigger
If Message = "!pickuser" then

  'get all nicks
  AllNicks = Nicks(Channel,ServerNumber)

  'split the nicks into an array
  NickArr = Split(AllNicks," ")

  'get a random number within the range of the array
  NickNr = GetIdentifier("$rnd(0," & UBound(NickArr) & ")"

  'send the message
  SendCommand "/msg " & Channel & " !! " & NickArr(NickNr) & " !! ",ServerNumber
End If
End Sub

You might wanna look up som vbscript guide (google it), because most of the stuff you're asking for is really basic stuff.
"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

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Re: "Picker Bot"
« Reply #2 on: March 22, 2008, 10:03:23 AM »
Thanks Morio
~ Sam
~ Visit my website at http://www.TheCellist42.com

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Re: "Picker Bot"
« Reply #3 on: March 22, 2008, 10:06:05 AM »
[12:05]  ->> ERROR:modScriptFunctions:WINNER!.ice:Function:LoadScriptFile: Error Number:1006 : Expected ')'

I keep getting this, I tried to fix it, but...
~ Sam
~ Visit my website at http://www.TheCellist42.com

Morio

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Re: "Picker Bot"
« Reply #4 on: March 22, 2008, 01:04:11 PM »
See, this is why you should read some vbscript tutorial, or at least read the error message. It says that there's a ')' missing.

It's from the NickNr line
"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

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Re: "Picker Bot"
« Reply #5 on: March 22, 2008, 02:01:56 PM »
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)

'check for the trigger
If Message = "!winner" then

  'get all nicks
  AllNicks = Nicks(Channel,ServerNumber)

  'split the nicks into an array
  NickArr = Split(AllNicks," ")

  'get a random number within the range of the array
  NickNr = GetIdentifier("$rnd(0," & UBound(NickArr) & ")"

  'send the message
  SendCommand "/msg " & Channel & " !! " & NickArr(NickNr) & " !! ",ServerNumber
End If
End Sub

I Still get the error, and I apparently have no idea what I'm doing
~ Sam
~ Visit my website at http://www.TheCellist42.com

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: "Picker Bot"
« Reply #6 on: March 22, 2008, 02:43:25 PM »
You need another bracket on the line

NickNr = GetIdentifier("$rnd(0," & UBound(NickArr) & ")")  <<-- at the end of the line. The total amount of brackets always have to be equal, for opening and closing brackets, thats always a rule of thumb.

Also, there is a simpler way to get a random number.


Replace the line
Code: [Select]
NickNr = GetIdentifier("$rnd(0," & UBound(NickArr) & ")" with 
Code: [Select]
NickNr = Int(Rnd * Ubound(NickArr)) + 1
The IceChat God

Jacob

  • Newbie
  • *
  • Posts: 45
Re: "Picker Bot"
« Reply #7 on: March 30, 2008, 01:56:59 PM »
Use in a allie

/Rand //say $nick(<channel>,$rnd($nick(<same Channel>,0)))

TheCellist42

  • Full Member
  • ***
  • Posts: 143
    • TheCellist42.com
Re: "Picker Bot"
« Reply #8 on: March 30, 2008, 09:15:59 PM »
Using The Codes From Snerf and Morio, It works Now, And I Even HAd To Add A Line To Make It So Only I Could Use It Because Too Many People Were Spamming it

 :-D
~ Sam
~ Visit my website at http://www.TheCellist42.com