mIRC Home    About    Download    Register    News    Help

Print Thread
Action on a certain name. #223262 20/07/10 01:07 AM
Joined: Jul 2010
Posts: 5
C
Casmo Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jul 2010
Posts: 5
Hi guys :]

I have a script that catches trouts.
But can I set an action for each nickname?
(Or just a few, and an action if someone else slaps someone)
Like in a text file, or in aliases or something?
Because if I'd do anything in the script itself it would become messy (which it is now, because I have a few names added already...)

Thanks in advance :]

Greetings,
Casmo.

Re: Action on a certain name. [Re: Casmo] #223264 20/07/10 02:17 AM
Joined: Mar 2006
Posts: 10
S
strac Offline
Pikka bird
Offline
Pikka bird
S
Joined: Mar 2006
Posts: 10
you can create a several different variables such as %nick1 %nick2 that contain the names you're looking for and then use an if then else system: if ( $nick isin %nick1 ) { do this action }

Last edited by strac; 20/07/10 02:18 AM.
Re: Action on a certain name. [Re: Casmo] #223267 20/07/10 06:22 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can put all the nicknames in a text file line by line, one nickname per line. Then use:
Code:
 if ($read(slap.txt,w,$nick)) {
 ;do something
To match certain nicknames stored in the slap.txt for example.

Using isin operator is not a good choice because it can result false positives.

Re: Action on a certain name. [Re: Casmo] #223270 20/07/10 10:46 AM
Joined: Jul 2010
Posts: 5
C
Casmo Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jul 2010
Posts: 5
@strac

That seems like what I do already, but not using the variables as it seems that I'd just replace the nickname for a variable...


@Tomao

Can you explain that please? :]
Can I put the actions inside the textfile as well?

Quote:

if ($nick == randomnick) {
describe $chan steals the trout


Can that be made like this:
if randomnick slaps that it reads the actions from a textfile?

Example:

Quote:

if ($nick == randomnick) {
describe $chan steals the trout
<read action from file here>

Re: Action on a certain name. [Re: Casmo] #223273 20/07/10 11:39 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Text file:
Quote:

nick throws a tomato at nick.
nick2 runs away from nick2.


IF line in script:

Code:
if ($read(temp.txt,ntw,$nick *)) { describe $chan $gettok($v1,2-,32) }
else { describe $chan slaps $nick back with a large trout. }


That's just one example of how you can do it. Note that this example


Invision Support
#Invision on irc.irchighway.net
Re: Action on a certain name. [Re: Riamus2] #223274 20/07/10 12:01 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Quote:
nick throws a tomato at nick.
nick2 runs away from nick2.

Just some constructive criticism if you use the above format: instead of the w switch I'd recommend using the s switch in this case.
(See /help $read for what the difference is)
Code:
if ($read(temp.txt,nts,$nick)) { describe $chan $v1 }
else { describe $chan slaps $nick back with a large trout. }

Re: Action on a certain name. [Re: 5618] #223276 20/07/10 12:18 PM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
the 'w' switch is arguably more suitable since it returns the matching nick, generally leading to a satisfied if condition. with 's', everything after the search term is returned; when you have one nick per line it will return $null which will effectively falsify the condition (that's why a noop $read(...) | if ($readn) combination is often seen). * ? and & are typically not allowed in nicknames, but you're quite right that in general it is important to make that distinction :P

the same could be said about 'n' and nicknames not typically being allowed a % or $ prefix, but it changes nothing to include it here and is something a lot of people often omit.

Edit: ah, forgive me, i didn't see past the first $read(file,w,$nick) check :P i believe you want $v1 in place of $1- there


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Re: Action on a certain name. [Re: 5618] #223283 20/07/10 03:20 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, I went back and forth with using s or w and opted for w. Either should work fine and s would be fewer characters/commands and probably faster. I'm not really sure anymore why I went with w instead of s there. *shrug*

You'll just want $v1 instead of $1- for your example as mentioned. smile


Invision Support
#Invision on irc.irchighway.net
Re: Action on a certain name. [Re: Casmo] #223287 20/07/10 06:23 PM
Joined: Jul 2010
Posts: 5
C
Casmo Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jul 2010
Posts: 5
I'm sorry, but I can hardly understand it...

Can someone please post what's in the text file, and what's in the remote script? (Because I can't figure it out how it works... and I can't find it on Google )

Say, I have 2 people that can slap me.
Nick1 and Nick2, and I want to slap them back, but a different message for each nick.

Say for nick1 I want to slap it back with: describe $chan slaps nick1 back and eats the trout.

For nick2 I want: describe $chan slaps nick2 back, and throws the trout back into the river.


Now what do I put into remotes, and what do I put into the textfile? :X

Re: Action on a certain name. [Re: Casmo] #223288 20/07/10 06:54 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Code:
on $*:action:$(/\b(slaps?) \Q $+ $me $+ \E\b/iS):*:{
  if (!%x) { inc -u5 %x
    var %slapnick = nick1 nick2 nick3 nick4 nick5 nick6
    describe $iif(#,#,$nick) $regml(1) $nick back $iif($istok(%slapnick,$nick,32),and eats the trout.,and throws the trout back into the river.)
  }
}
Replace nick1, nick2, nick3, etc..with the nicknames you want them to be slapped. (There's a space between each added as shown) Those who are not added in the local variable %slapnick will get the message as, "Casmo slaps nick back and throws the trout back into the river. Conversely, those who are added in the %slapnick var will get the message as, "Casmo slaps nick back and eats the trout."

Re: Action on a certain name. [Re: Casmo] #223292 20/07/10 08:25 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Casmo
Can someone please post what's in the text file, and what's in the remote script?


If you look at my post, I showed both the text file and the script file. We talked about changing it around a bit, but what I showed will work correctly.


Invision Support
#Invision on irc.irchighway.net
Re: Action on a certain name. [Re: Tomao] #223297 20/07/10 10:40 PM
Joined: Jul 2010
Posts: 5
C
Casmo Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jul 2010
Posts: 5
Originally Posted By: Tomao
Code:
on $*:action:$(/\b(slaps?) \Q $+ $me $+ \E\b/iS):*:{
  if (!%x) { inc -u5 %x
    var %slapnick = nick1 nick2 nick3 nick4 nick5 nick6
    describe $iif(#,#,$nick) $regml(1) $nick back $iif($istok(%slapnick,$nick,32),and eats the trout.,and throws the trout back into the river.)
  }
}
Replace nick1, nick2, nick3, etc..with the nicknames you want them to be slapped. (There's a space between each added as shown) Those who are not added in the local variable %slapnick will get the message as, "Casmo slaps nick back and throws the trout back into the river. Conversely, those who are added in the %slapnick var will get the message as, "Casmo slaps nick back and eats the trout."


But I don't want 2 groups of people..
I want to be able to have say 10 different people, which is why I want it to read from a textfile...

Originally Posted By: Riamus2
Originally Posted By: Casmo
Can someone please post what's in the text file, and what's in the remote script?


If you look at my post, I showed both the text file and the script file. We talked about changing it around a bit, but what I showed will work correctly.


I didn't understand that script at all... Shouldn't there be like actions in the text file as well? :|


Re: Action on a certain name. [Re: Casmo] #223303 21/07/10 12:00 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I find it burdensome to use a text file when you can do it in the script. And I don't see it as messy in any way. You can reconstruct the script like so:
Code:
on $*:action:$(/\b(slaps?) \Q $+ $me $+ \E\b/iS):*:{
  if (!%x) { 
    inc -u5 %x
    var %group1 = nick1 nick2 nick3 nick4 nick5 nick6
    var %group2 = nick1 nick2 nick3 nick4 nick5 nick6 nick7 nick8
    var %group3 =
    var %group4 =
    var %group5 =
    if ($istok(%group1,$nick,32)) {
      describe $iif(#,#,$nick) $regml(1) $nick back and eats the trout.
    }
    elseif ($istok(%group2,$nick,32)) {
      describe $iif(#,#,$nick) $regml(1) $nick back and throws the trout back into the river.
    }
    elseif ($istok(%group3,$nick,32)) {
      ;another message
    }
So on and so forth...

Re: Action on a certain name. [Re: Tomao] #223305 21/07/10 01:16 AM
Joined: Jul 2010
Posts: 23
B
botnoob Offline
Ameglian cow
Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Ok, so here is my version of the 'SlapBack' script (as I call it)

Quote:
on *:ACTION:slaps*:#: {
if ($me == botnoob) HALT
if ($2 == $me) {
if ($nick == becca) || ($nick == rez) || ($nick == Gem) { describe $chan thanks for the slap, oh and by the way hows your momma doing? $nick }
else {
describe $chan slaps $nick back harder.
}
}
}

In short terms if becca rez or gem slaps you they get the "thanks for the slap, oh and by the way hows your momma doing?" message. Anybody else in the channel gets slapped back harder.

Also, if you want danny and bob to get a 'kill' message just add another if ($nick == becca) || ($nick == rez) || ($nick == Gem) { describe $chan thanks for the slap, oh and by the way hows your momma doing? $nick } <change the message, and names>

So it would end up as:

Quote:
on *:ACTION:slaps*:#: {
if ($me == botnoob) HALT
if ($2 == $me) {
if ($nick == becca) || ($nick == rez) || ($nick == Gem) { describe $chan thanks for the slap, oh and by the way hows your momma doing? $nick }
if ($nick == danny) || ($nick == bob) { describe $chan kills $nick }
else {
describe $chan slaps $nick back harder.
}
}
}



And just keep adding them in for all different people and different messages.
Hope this helps.

botnoob

Last edited by botnoob; 21/07/10 01:41 AM.
Re: Action on a certain name. [Re: Casmo] #223308 21/07/10 02:10 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Casmo

I didn't understand that script at all... Shouldn't there be like actions in the text file as well? :|



Quote:
nick throws a tomato at nick.
nick2 runs away from nick2.


There *are* actions there. i.e. "throws a tomato at nick." or "runs away from nick2." They will automatically be actions.

This is it with real nicks:

Quote:

Casmo throws a tomato at Casmo.
Riamus runs away from Riamus.


The first word is the nick who you are watching and the rest is the action. You can include their nick in the action or not depending what you want it to say.


Invision Support
#Invision on irc.irchighway.net
Re: Action on a certain name. [Re: Riamus2] #223312 21/07/10 02:13 AM
Joined: Jul 2010
Posts: 23
B
botnoob Offline
Ameglian cow
Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
It works pretty fine for me. Maybe pop it in and see how you go with it. Its not like you cannot delete it when you have checked.

Last edited by botnoob; 21/07/10 02:14 AM.
Re: Action on a certain name. [Re: botnoob] #223327 21/07/10 06:43 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
botnoob, your script can be improved a bit:
Code:
on *:ACTION:slaps*:#: {
  if (($me != botnoob) && ($2 == $me)) {
    if ($istok(becca rez Gem,$nick,32)) {
      describe $chan thanks for the slap, oh and by the way hows your momma doing? $nick 
    }
    elseif ($istok(danny bob,$nick,32)) { describe $chan kills $nick }
    else { describe $chan slaps $nick back harder. }
  }
}

Re: Action on a certain name. [Re: Tomao] #223334 21/07/10 10:04 AM
Joined: Jul 2010
Posts: 23
B
botnoob Offline
Ameglian cow
Offline
Ameglian cow
B
Joined: Jul 2010
Posts: 23
Yeah, I have only been scripting for about 3-4 weeks now, so im sure i will get the hang of it (eventually) lol

Thanks for the heads up though. I think I will check the new one you pasted and see how it goes.


Oh and we hope this has helped you with your post casmo.

Kind Regards
-botnoob-

Last edited by botnoob; 21/07/10 10:04 AM.
Re: Action on a certain name. [Re: Casmo] #223339 21/07/10 11:50 AM
Joined: Feb 2009
Posts: 133
C
chacha Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
if you want you can create a file and add several lines of slap back
and the code will be
Code:
on $*:action:$(/\bslaps?\Q $+ $me $+ \E\b/iS):*:{
  if !%w {
    inc -u3 %w
    describe $iif(#,#,$nick) $read(file.txt)
  }
}

then you have a random slap back to every nick


WorldDMT
Re: Action on a certain name. [Re: botnoob] #223389 22/07/10 07:51 PM
Joined: Jul 2010
Posts: 5
C
Casmo Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Jul 2010
Posts: 5
Thanks all, got it working.

Last edited by Casmo; 22/07/10 08:58 PM.