|
|
Joined: Aug 2010
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: Aug 2010
Posts: 2 |
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...
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
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.
|
|
|
|
Joined: Nov 2006
Posts: 1,559
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,559 |
If you know a bit about regular expressions, you could refine your event with back references, like in (just an example) 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) $+ ! }
}
}
|
|
|
|
Joined: Jul 2007
Posts: 1,129
Hoopy frood
|
Hoopy frood
Joined: Jul 2007
Posts: 1,129 |
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.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
There's always the more obvious (less robust) match of: 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.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jan 2010
Posts: 9
Nutrimatic drinks dispenser
|
Nutrimatic drinks dispenser
Joined: Jan 2010
Posts: 9 |
on @*:action:$(slaps $me *):# {
describe # $replace($1-,$me,$nick)
}
is easier surely? :P Since not everyone will slap someone "about with a" something
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
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.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Aug 2010
Posts: 2
Bowl of petunias
|
OP
Bowl of petunias
Joined: Aug 2010
Posts: 2 |
Thanks for your help guys, much appreciated.
Got it to work the way I wanted.
|
|
|
|
|
|