Typo commented on a Page, !bomb  -  Jul 10, 2008

Hi Seven_Dayys. I\'m trying to get to bed so excuse any errors and I will answer any questions when I get up tomorrow or if you have any I\'m sure another user can help before I get back on here anyhow.

Try this out. I did not take the time to look into detail at all the code. I simply took and shortened everything into one nice little on text event.

on *:TEXT:*:#: {
  if ($1 == !bomb) {
    if ($2 == $me) { kick # $nick You wanna bomb me?!! | halt }
    elseif ($2 == $nick) || (%bomb == $null) {
      set -u10 %bomb 1
      if ($2 ison $chan) && ($me isop $chan) || ($me ishop $chan) {
        set %bomber $nick   
        set %kicknick $2
        set %sec $rand(10,30)
        set %color $rand(1,3)
        set %time $calc( %sec / 1/2 )
        if ($2 != $nick) { msg $chan  $+ $nick planning a bomb on $2 $+ \'s butt and will explode in %sec seconds! }
        else { msg $chan Whoa, u wanna suicide, $nick $+ ? Okay, the bomb will explode in %sec seconds! }
        msg $chan  $+ $2 $+ , type 4!red, 12!blue or 3!green to cut the wire and deactive the bomb!
        if (%color == 1) { set %color !red }
        if (%color == 2) { set %color !blue }
        if (%color == 3) { set %color !green }
        .timer 1 %time msg #  $+ %time seconds remaining!!
        .timer 1 %sec kick # %kicknick 4(((~~~~~KABOOOOOMMM!!!!~~~~~))) $iif($2 == $nick,Time\'s up, dude!,Congratulation, You were bombed by $nick $+ !)
      }
    }
  }
  if ($nick == %kicknick) && ($1 == %color) { msg $chan Great, the bomb is off! | unsetem }
  elseif ($nick == %kicknick) && ($1 == !red) || ($1 == !green) || ($1 == !yellow) { kick $chan %kicknick 4(((~~~~~KABOOOOOMMM!!!!~~~~~))) You just pick up the wrong wire! | unsetem }
}
alias unsetem {
  .timers off
  unset %kicknick
  unset %bomber
}

The four major things to learn from this is, one, combine all on text events into one whenever possible by using:

on *:TEXT:*:#: { 
  if ($1 == !a) { !a\'s commands }
  if ($1 == !b) { !b\'s commands }
} 

Two, use || for OR and && for AND when building an IF line such as:

If (1 == 1) && (2 == 2) || (3 == 3) { commands }

Three use $iif to throw an if statement into a line to combine lines uch as:

msg $chan I am currently $iif($away == $true,Away,Here)

Instead of using two lines like IF ($away == $true) {msg bla away } and else { msg bla here }
For help on the $iif type /help $iif in mirc for more info. Even expert scripters use the help file all the time, it is very very handy.
And lastly, when you have repetetive code, put it into its own alias to call it like a command or a $command such as:

alias dosomethings {
  unset %settings
  .timers off
  .msg people
  .etc
  .etc
  .etc
}

Which you could then access throughout your script like any normal alias. Its even a good system to use if you have the same message sent a ton of times. Like:

alias mymessage {
.msg $1 My message is in this line and it would be very long no doubt and its a msg I will need to use again and again in this script. 
}

Then you could call it any time by:

On *:text:*:#:{
  if ($chan != $null) { $mymessage($chan }
  elseif ($nick != $null) { $mymessage($nick) }
}
On *:join:#:{ $mymessage($nick) }

The above code is silly but it was just to show a point.

Anyhow, Good Luck and I hope this is a decent help to you.

Btw, that was taken from 75 lines down to 37 :)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.