mIRC Home    About    Download    Register    News    Help

Print Thread
#224064 05/08/10 01:53 AM
E
ExpecZ0r
ExpecZ0r
E
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...

#224070 05/08/10 02:50 AM
Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
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.

#224071 05/08/10 03:01 AM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
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) $+ ! }
  }
}


Horstl #224076 05/08/10 04:41 AM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
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.

#224082 05/08/10 06:27 AM
Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
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.

argv0 #224091 05/08/10 08:56 AM
L
Litch
Litch
L
Code:
on @*:action:$(slaps $me *):# {
  describe # $replace($1-,$me,$nick)
}


is easier surely? :P

Since not everyone will slap someone "about with a" something

#224109 05/08/10 01:25 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
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.

E
ExpecZ0r
ExpecZ0r
E
Thanks for your help guys, much appreciated.

Got it to work the way I wanted.


Link Copied to Clipboard