mIRC Homepage
Posted By: Justin_F Counting the number of times I say a word. - 06/02/10 08:26 PM
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
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
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
Posted By: Wims Re: Counting the number of times I say a word. - 06/02/10 08:39 PM
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
}

Posted By: Tomao Re: Counting the number of times I say a word. - 06/02/10 10:41 PM
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.
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.

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.
Posted By: Tomao Re: Counting the number of times I say a word. - 07/02/10 08:21 AM
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.)
}
hi
try this
Code:
on *:text:!amount:#:notice $nick You have $iif($($+(%,$nick),2),$v1,nothing) $+ .

Posted By: Tomao Re: Counting the number of times I say a word. - 09/02/10 01:25 AM
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.
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).
Posted By: Tomao Re: Counting the number of times I say a word. - 09/02/10 07:39 AM
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..
Posted By: 5618 Re: Counting the number of times I say a word. - 09/02/10 08:18 AM
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.
© mIRC Discussion Forums