mIRC Homepage
Posted By: ExpecZ0r Help with Script - 05/08/10 01:53 AM
I currently have a script by which if someone slaps me it removes them from the channel.

But if they slap me with a different item than trout, it uses a message I made that retaliates with a trout.

How do I edit it so as to make it retaliate with the item they slap me with e.g. X slaps Me about with a (stick), so as to retaliate with the item in the bracket.

Any help would be appreciated, and my script is shown below.

On @*:action:$($+(*,slap,*,$me,*)):#:{
.timer 1 1 describe # dodges $nick $+ 's slap!
.timer 1 3 msg # shoves the trout up $nick 's ass so hard it sends him flying out of chat
.timer 1 5 kick # $nick Poor Trout...
Posted By: RusselB Re: Help with Script - 05/08/10 02:50 AM
If you know that the item the offender is trying to slap you with is located at the end of the line, then in your ON ACTION event you can use $gettok($1-,-1,32) to return the name of the item.

However, if the location of the item varies, then this is more complicated, possibly impossible with mIRC's current scripting restrictions.
Posted By: Horstl Re: Help with Script - 05/08/10 03:01 AM
If you know a bit about regular expressions, you could refine your event with back references, like in (just an example)
Code:
on @*:action:*:#: {
  if ($regex($1-,/^slaps? $+(\Q,$me,\E) ?(.*)/Si)) {
    ; whatever your action for no slap item
    if (!$regml(1)) { msg $chan ouch! }
    ; whatever your action for a trout slap
    elseif (trout isin $regml(1)) { describe $chan eats the trout - yummy! }
    ; whatever your action for a different slap
    else { describe $chan slaps $nick back $regml(1) $+ ! }
  }
}

Posted By: Tomao Re: Help with Script - 05/08/10 04:41 AM
Well, you could put the regex in the action match text section...thus it'll save an if condition. I know that'll do the same thing anyway.
Posted By: argv0 Re: Help with Script - 05/08/10 06:27 AM
There's always the more obvious (less robust) match of:

Code:
on @*:ACTION:$(slaps $me about with a *):#: {
  describe # slaps $nick about with a $6-
  ; ...
}


Of course it's usually "around", not "about", and the user could easily omit the object altogether, so a regex match would handle this more elegantly.
Posted By: Litch Re: Help with Script - 05/08/10 08:56 AM
Code:
on @*:action:$(slaps $me *):# {
  describe # $replace($1-,$me,$nick)
}


is easier surely? :P

Since not everyone will slap someone "about with a" something
Posted By: Riamus2 Re: Help with Script - 05/08/10 01:25 PM
However you do it, just remember that if you don't put in some kind of flood protection, you can easily end up in a loop with someone else who has a similar script and get yourself kicked for excess flood. The simplest method is to put in a 1 second named timer on the /describe line. That should at least prevent you from being kicked for excess flood. If you want to do even more to prevent just flooding the channel (without being kicked), then you probably want to put a limit on it where it won't trigger more than once every 5-10 seconds.
Posted By: ExpecZ0r Re: Help with Script - 05/08/10 02:42 PM
Thanks for your help guys, much appreciated.

Got it to work the way I wanted.
© mIRC Discussion Forums