mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2007
Posts: 31
J
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2007
Posts: 31
I want a basic script that counts the amount of times I say a certain word. (Only 1 count per line)
Say the word is "yankees". I want it to count each time I say that word in a line.
I tried
On *:INPUT:#:{
if ($1 == yankees) {
inc %yankees
}
}
This works but will only count if "yankees" is the first or only word in the line. I want it to count lines like uhh "What about them yankees?" lol.
I tried putting stars around the word but that caused the script not to work. So basically I'm asking how to make the script work if the word is used anywhere in a line I said.
Thanks -Justin

Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
Code:
on *:input:#:{
if (yankees isin $1-) {
inc %yankees
}
} 


The key issue is that you were only checking $1 (the first word), not the entire string ($1-)
Checkout isin, isincs in the help file.

Cheers,

DK

Last edited by Darwin_Koala; 06/02/10 08:34 PM.

Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
Joined: Jan 2007
Posts: 31
J
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2007
Posts: 31
Originally Posted By: Darwin_Koala
Code:
on *:input:#:{
if (yankees isin $1-) {
inc %yankees
}
} 


The key issue is that you were only checking $1 (the first word), not the entire string ($1-)
Checkout isin, isincs in the help file.

Cheers,

DK


Wow that was really fast! Thanks alot works perfect laugh

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Since he talks about words, $istok should be used instead of isin :
I've added $strip and this also let you trigger the script when you type in any windows, not just in channel windows.

on *:input:*:{
if ($istok($strip($1-),yankees,32)) inc %yankees
}



#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I will recommend Wims' suggestion, as it matches exactly for the word "yankees." Using isin operator will match anything if someone says "daddyyankee" or any word that follows before or after it.

Joined: Jan 2007
Posts: 31
J
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jan 2007
Posts: 31
Again thanks for all the help! But I got another nooby question.
I want to make a simple script that uses the stored variables.

For instance say I got %YourNickName variable stored under the variable tab and it has "34" uses. I want to make a script that will say the amount of uses to a user if they do the command and their nickname matches the variable name.
So basically if your nickname is say JonJoe. And I have a variable called %jonjoe 34 under my variable tab in my remote menu. If you type "!amount" I want a script that will tell the user "The amount is 34" or whatever the number is.
I came up with something, but I cannot figure out to how combine the % with $nick.
Code:
on *:text:!amount*:#: {
  /notice $nick Hello $nick , you have % $+ $nick !
}

This dosent work, but there has to be someway to combine the % with the $nick so it reads a given variable.
Thanks in advance. I know this is a stupid question lol.

Joined: Nov 2009
Posts: 117
Vogon poet
Offline
Vogon poet
Joined: Nov 2009
Posts: 117

To set it: $+(%,something,$nick)
To read it: $($+(%,something,$nick),2)

If you do not use 'something' with dynamic variables based on $nick you risk variable name collisions. Also, makes it easy to unset the whole group.

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can use the evaluation brackets to match the $nick first with his or her %nick variable. This will match their variable %nicknames with their nicknames and then output the value that belongs to the user, just the way you want it:
Code:
on *:text:!amount:#: {
  notice $nick Your amount is $iif(% [ $+ [ $nick ] ],$ifmatch $+ .,not found.)
}

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
hi
try this
Code:
on *:text:!amount:#:notice $nick You have $iif($($+(%,$nick),2),$v1,nothing) $+ .



WorldDMT
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
What difference does it make?

Aside from the use of $($+()) and $v1, there's no difference between yours and mine. Also, $v1 won't work if the user happens to use an older version of mirc below 6.16.

I believe you can use $eval() and $var()/$var().value to do the same thing.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, it's true that it will do the same thing, but it's usually considered more appropriate/professional to use $+() than to use []'s.

Whether you choose $v1 or $ifmatch for compatibility doesn't really matter, of course. But 6.16 is really old now and there's no reason you can't expect users to use at LEAST that version if they use your script(s).


Invision Support
#Invision on irc.irchighway.net
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Well, although chances aren't that great these days, I've come across some users who stay using the older version of mirc for some reason. Some even use 6.12, which frets me..

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Originally Posted By: Tomao
Well, although chances aren't that great these days, I've come across some users who stay using the older version of mirc for some reason. Some even use 6.12, which frets me..

In my experience there are two main reasons why people use these old versions.
One being that people use cracked copies or fake keys and want to avoid the verification introduced in later versions.
The other being that they use (outdated) add-on scripts which use old mIRC executables (and are incompatible with newer versions).
Then of course there's laziness.


Link Copied to Clipboard