mIRC Home    About    Download    Register    News    Help

Print Thread
#224064 05/08/10 01:53 AM
Joined: Aug 2010
Posts: 2
E
Bowl of petunias
OP Offline
Bowl of petunias
E
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
R
Hoopy frood
Offline
Hoopy frood
R
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
H
Hoopy frood
Offline
Hoopy frood
H
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)
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,129
T
Hoopy frood
Offline
Hoopy frood
T
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
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
argv0 #224091 05/08/10 08:56 AM
Joined: Jan 2010
Posts: 9
L
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
L
Joined: Jan 2010
Posts: 9
Code:
on @*:action:$(slaps $me *):# {
  describe # $replace($1-,$me,$nick)
}


is easier surely? :P

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

Litch #224109 05/08/10 01:25 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
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
E
Bowl of petunias
OP Offline
Bowl of petunias
E
Joined: Aug 2010
Posts: 2
Thanks for your help guys, much appreciated.

Got it to work the way I wanted.


Link Copied to Clipboard