Author Topic: Time Script (simple but can't get it to work)  (Read 3883 times)

llama009

  • Newbie
  • *
  • Posts: 4
Time Script (simple but can't get it to work)
« on: January 25, 2006, 11:35:12 PM »
Ok I am trying to make a script so that when anyone starts a line (in channel )with "what time" it will automatically send a message like "the time is 5:32:17pm tuesday 29th july 2006 in woop woop wallamaloo"

I have tried the following but none work.
Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)   
  if left(Message,9) = "what time" then   
String MsgTxt = "$time $day $month $year" 
SendCommand "/msg " & chan & /mytime   
end if   
End sub

where /mytime is an alias for $time

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
if Message = "what time"   
   SendCommand "//msg Channel $time   
end if   
End Sub   

Code: [Select]

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)         

'this checks for the word "what time"  in the Message         
if instr(Message,"what time") then         
SendCommand "/msg " & Channel & "The time where llama lives is" & $time & " on the " & $day & " of " & $month & $year & ".",ServerNumber         
end if         
End Sub         

Any help is greatly appreciated

« Last Edit: January 26, 2006, 12:37:47 AM by llama009 »

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Time Script (simple but can't get it to work)
« Reply #1 on: January 26, 2006, 07:41:11 AM »
Hello

You were close on some of those , but this is how you would do it.

Code: [Select]
Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)   
  if left(Message,9) = "what time" then   
   SendCommand "//msg " + Channel + " The time where llama lives is $time on $weekday $day of $month / $year", ServerNumber
  end if
End Sub

You did not have a space before "The  .. so the message gets send like "/msg #ChannelThe Time.. sending it to the wrong channel.
Also, the $identifiers can stay inside the quotes, as those are not variables used in the Script itself, like 'Channel', 'Message' and 'ServerNumber'
One last thing, I saw in your 1st you wanted to make a string. You dont make variables like that in VB Script.
I would suggest reading the scripting section in the help, under Learning to Use IceChat, VBScript Help.
Code: [Select]
Dim MsgTxt
MsgTxt = "Some text to use"

Thata about it, have fun :)

The IceChat God

llama009

  • Newbie
  • *
  • Posts: 4
Re: Time Script (simple but can't get it to work)
« Reply #2 on: January 26, 2006, 03:49:04 PM »
Thanks. Works great.