IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: TheCellist42 on March 21, 2008, 07:38:11 PM

Title: "Picker Bot"
Post by: TheCellist42 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?
Title: Re: "Picker Bot"
Post by: Morio 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.
Title: Re: "Picker Bot"
Post by: TheCellist42 on March 22, 2008, 10:03:23 AM
Thanks Morio
Title: Re: "Picker Bot"
Post by: TheCellist42 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...
Title: Re: "Picker Bot"
Post by: Morio 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
Title: Re: "Picker Bot"
Post by: TheCellist42 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
Title: Re: "Picker Bot"
Post by: Snerf 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
Title: Re: "Picker Bot"
Post by: Jacob on March 30, 2008, 01:56:59 PM
Use in a allie

/Rand //say $nick(<channel>,$rnd($nick(<same Channel>,0)))
Title: Re: "Picker Bot"
Post by: TheCellist42 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