mIRC Home    About    Download    Register    News    Help

Print Thread
Counting the number of times I say a word. #218238 06/02/10 08:26 PM
Joined: Jan 2007
Posts: 31
J
Justin_F Offline OP
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

Re: Counting the number of times I say a word. [Re: Justin_F] #218239 06/02/10 08:32 PM
Joined: Feb 2004
Posts: 206
D
Darwin_Koala Offline
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!
Re: Counting the number of times I say a word. [Re: Darwin_Koala] #218240 06/02/10 08:38 PM
Joined: Jan 2007
Posts: 31
J
Justin_F Offline OP
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

Re: Counting the number of times I say a word. [Re: Darwin_Koala] #218241 06/02/10 08:39 PM
Joined: Jul 2006
Posts: 3,697
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,697
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
}



Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Counting the number of times I say a word. [Re: Justin_F] #218243 06/02/10 10:41 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.

Re: Counting the number of times I say a word. [Re: Justin_F] #218260 07/02/10 06:04 AM
Joined: Jan 2007
Posts: 31
J
Justin_F Offline OP
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.

Re: Counting the number of times I say a word. [Re: Justin_F] #218262 07/02/10 06:30 AM
Joined: Nov 2009
Posts: 117
gooshie Offline
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.

Re: Counting the number of times I say a word. [Re: Justin_F] #218263 07/02/10 08:21 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.)
}

Re: Counting the number of times I say a word. [Re: Justin_F] #218295 08/02/10 11:55 AM
Joined: Feb 2009
Posts: 133
C
chacha Offline
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
Re: Counting the number of times I say a word. [Re: chacha] #218315 09/02/10 01:25 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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.

Re: Counting the number of times I say a word. [Re: Tomao] #218320 09/02/10 02:16 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
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
Re: Counting the number of times I say a word. [Re: Riamus2] #218324 09/02/10 07:39 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
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..

Re: Counting the number of times I say a word. [Re: Tomao] #218325 09/02/10 08:18 AM
Joined: Jun 2007
Posts: 933
5
5618 Offline
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.