Author Topic: Yet another question . . . Timebombing script  (Read 5174 times)

Primate

  • Newbie
  • *
  • Posts: 9
Yet another question . . . Timebombing script
« on: September 10, 2006, 01:12:16 PM »
I am making a timebomb script, but I need some help. this is my script so far:
Code: [Select]
Dim Timebomb
Timebomb = 36

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
  if Channel = "#primate" then
  if ( Instr(Message,"!timebomb") ) then
    Timebomb = Timebomb + 5
    SendCommand "/msg #primate $2 has been timebombed. The display reads " & Timebomb & " seconds.", ServerNumber
    SendCommand "/timer $rndtimer 1 " & Timebomb & " /kick #primate $2 You were timebombed by " & Nickname & "."
    SendCommand "/timer $rndtimer 1 " & Timebomb-2 & " /msg #primate tick, tick, tick . . ."
    SendCommand "/timer $rndtimer 1 " & Timebomb-1 & " /msg #primate BOOM!"
    if Timebomb = 56 then
      Timebomb = 36
      SendCommand "/notice Primate Timebomb has been reset"
    End if
  End if
End if
End Sub

Obviously, when someone says !timebomb <nickissupossedtobehere> it says has been timebombed. 36 seconds later, it reads tick, tick tick . . BOOM! and finally [16:25] ->> You :No such nick/channel. Apparently $2 doesn't work in VB scripting. What's the code to get the text after !timebomb?

Thx again,
Primate
« Last Edit: September 10, 2006, 01:14:28 PM by Primate »

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Yet another question . . . Timebombing script
« Reply #1 on: September 10, 2006, 01:19:49 PM »
Your right, $2 does not work in vb scripting.
What you need to do is extra the 2nd word from Message variable. To do that, you use Mid and Instr. You look for a space in Message, and then go to the next character, and there is your next word. This will error out though, if there is no space/2nd word.
So, lets say you call the variable BombNick.

BombNick = Mid(Message, Instr(Message," ") + 1)
The IceChat God

Primate

  • Newbie
  • *
  • Posts: 9
Re: Yet another question . . . Timebombing script
« Reply #2 on: September 10, 2006, 01:57:51 PM »
Awesome, it works now. Thanks for telling me about Mid, that's the command i was looking for. Here's my finished script:

Quote
Dim Timebomb
Timebomb = 36

Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber)
Dim Victim
Victim = Mid(Message, Instr(Message," ") + 1)

if  ISOP(Victim,"#primate",ServerNumber) = True or ISHALFOP(Victim,"#primate",ServerNumber) = True then
SendCommand "/kick #primate " & Nickname & " You didn't timebomb the right way so it's you're lucky day!"

else

  if Channel = "#primate" then
  if ( Instr(Message,"!timebomb") ) then
   
    SendCommand "/msg #primate 3" & Victim & " has been timebombed. The display reads " & Timebomb & " seconds.", ServerNumber
    SendCommand "/timer $rndtimer 1 " & Timebomb & " /kick #primate " & Victim & " You were timebombed by " & Nickname & "."
    SendCommand "/timer $rndtimer 1 " & Timebomb-2 & " /msg #primate 6tick, tick, tick . . ."
    SendCommand "/timer $rndtimer 1 " & Timebomb-1 & " /msg #primate 4BOOM!"
    Timebomb = Timebomb + 5
    if Timebomb = 56 then
      Timebomb = 36
      SendCommand "/notice Primate Timebomb has been reset"
    End if
  End if
End if
End if
End Sub

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Yet another question . . . Timebombing script
« Reply #3 on: September 10, 2006, 02:21:28 PM »
I would suggest that you add a ",ServerNumber" at the end of each SendCommand line, because otherwise it will send it to the current server, which may not be the one you want it to send on. This is all because of the MultiServer capabilites of IceChat.

Also, the script below will error out, if there is just a single word spoken.
And every time a message is spoken. it is checking for IsOP and IsHalfOp. What I suggest is, first check for the !timebomb keyword and the channel #primate, and then check for the Victim, and IsOP/IsHalfOp, etc coding. It is just a bit of re-arranging, but you will get less problems with it, and it will run quicker as well.
The IceChat God

Primate

  • Newbie
  • *
  • Posts: 9
Re: Yet another question . . . Timebombing script
« Reply #4 on: September 10, 2006, 06:05:17 PM »
Thx for the help, it is faster now. However, I had to completely re type the script because i tried switching them around--it gave me an error, then I reverted back, and it still didn't work. But now it's completely fixed with (hopefully) perfect VB scripting.

Snerf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1968
    • IceChat IRC Client
Re: Yet another question . . . Timebombing script
« Reply #5 on: September 10, 2006, 10:46:28 PM »
Lots of fun and games, but thats how you learn, screw it all up, and then try and fix it :)
The IceChat God